Non-recursive file move with multiple Wildcards [closed] - windows

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
How would I alter this code to make it non-recursive?
FOR /R %pathold% %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
move "%%G" %pathnew%>NUL
echo %%G
)
I tried using ForFiles, but it doesn't support multiple Wildcards.
ForFiles /P %pathold% /M *.tif *.tiff *.jpg *.jpeg *.pdf /C "move #path %pathnew%"
ERROR: Invalid argument / option - '* .tiff'.

So in order to use only the root Directory remove the /R %pathold% from the Code above so it looks like this:
FOR %%G in (*.tif *.tiff *.jpg *.jpeg *.pdf) do (
move "%%G" %pathnew%>NUL
echo Moving %%G
)
Important to note:
You have to be in the Directory you wan't to move from.
You can do this with cd %oldpath% or pushd %oldpath% for example.

Related

Batch: sorting PDF's with letters and numbers in [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I am tasked with a batch sorting script. And i don't know how to start.
I have thousand of PDF files and they are generated with a number, some are generated with a letter either O or P, they need to be sorted into a separate folder.
For now all i got is:
xcopy "c:\Test 1" "c:\Test 1\sorted" /y
pause
But have no idea how to proceed.
//Merry Christmas
Give this a try.
#echo off
PUSHD "c:\Test 1"
MD SORTED 2>nul
FOR %%G IN (*O.pdf *P.PDF) DO MOVE "%%G" SORTED
POPD
#ECHO OFF
set pathtoFolder="C:Test 1"
set destination="C:\Test 1\Sorted"
FOR /R %pathtoFolder% %%G IN (*O.txt *P.txt) DO (
echo %%G
xcopy %%G %destination%
)
Based upon the comments, I'm assuming that the O and P are at the end of the file. Leave a comment if there are any errors, and I shall correct.

FOR statement to parse datetime stamp in file names [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
How will I accomplish the following in a FOR statement?
I have files in a windows PC directory that I want to identify by all or part of a datetime stamp that is part of the files name, ie-
CLIENT CODE / ID DATETIME STAMP
0000090000010009.CLIENTNAME.20121212140022.txt
0001090000010009.CLIENTNAME.20130916110025.txt
0001090000010009.CLIENTNAME.20130908150022.txt
I do not have to open/read the file. I just need to identify files in a particular date time range to either MOVE, DELETE or COPY them.
for /f "tokens=1-4delims=." %%a in ('dir /b /a-d "*.clientname.*.*"') do (
set "dts=%%c"
setlocal enabledelayedexpansion
set "yyyy=!dts:~0,4!"
set "mm=!dts:~4,2!"
set "dd=!dts:~6,2!"
set "hh=!dts:~8,2!"
set "min=!dts:~10,2!"
set "sec=!dts:~12,2!"
echo File: %%a.%%b.%%c.%%d date/time: !dd!/!mm!/!yyyy! -- !hh!:!min!:!sec!
endlocal
)
You can use the dir command with wildcard. So say you want the file 0000090000010009.CLIENTNAME.20121212140022.txt you can do:
dir *20121212140022*
If you want to put it in a loop then for /F will do the trick:
for /F %x in ('dir *20121212140022* /b /a-d ') do del %x

Findstr -- exclude a file type -- search only ascii [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I want to run a FINDSTR dos command in a way beyond what it is easily found in "findstr /?". How would I run findstr so that it only searches ascii files. (I am not sure if that is possible. My gut feeling is that it is not possible) Additionally, how would I run this command line so that it would exclude some file times. For example, what if I wanted to exclude .psd files
What is wrong with the /P option that is described in the help?
/P Skip files with non-printable characters.
It worked for me.
To take further control of which files are searched, simply iterate the files with a for loop and add whatever logic you need. To skip .psd files and also skip binary files:
for /f "eol=: delims=" %%F in ('dir /a-d /b^|findstr /live ".psd"') do findstr /p "search" "%%F"
Use a single percent instead of double percents if run from the command line.

Windows command prompt (Dos) copies all the files that start with the specified file name [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
In Dos if you type
copy c:\a.txt
it will copy a.txt* (a.txt1, a.txtb, etc)
how can I just copy a.txt?
Your question is not correct - copy c:\a.txt will only copy the single file to the current directory. It will ignore the other files like a.txt1 and a.txtb.
You must have tried copy c:\*.txt - that will copy all forms because the pattern matching searches both long and short (8.3) names.
You can eliminate the problem by using FINDSTR:
for /f "eol=: delims=" %F in ('dir /b /a-d c:\*.txt^|findstr /eli ".txt"') do #copy "c:\%F"

how to access server using cmd( \\Server\Volume\File) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
I need to get folder names in my server, as you know when you start cmd.exe it has default path name like "C:\Documents and ....". I can get folder names which are in my "C:/" by typing dir *.* /b /o:n > index.txt.
so I have this;
C:\Documents and Settings\Name>dir *.* /b /o:n > index.txt
I need this if there is a way;
\\Server\Volume\File>dir *.* /b /o:n > index.txt
sorry for my broken english, any help wellcome.
Use:
pushd \\Server\Volume
dir
popd
You could map the drive and then browse that directory:
net use Z: \\Server\Volume
cd /d Z:\
dir
Hope this helps :)

Resources