batch file to copy & increment

N/a / N/A
March 11, 2009 at 23:55:22
Specs: Windows XP, 2gb
I need a batch file to loop through a list of jpgs in a folder, & move them to folders created based on their file names in the following convention:

The folder names will be based on the first 8 characters of the file names, so 09-01556.A2.12.jpg would go in a folder called 09-01556.

I have the following so far which does the job nicely:

for /f %%F in ('dir/b/a-d *.jpg') do call :sub1 %%F
goto :eof

:sub1
set name=%1
md %name:~0,8%
move %* %name:~0,8%


BUT I also need to take account of situations where a jpg file is moved to the destination and it already exists. In this case, I do not want to overwrite, but need to increment the file name whilst preserving the 'previously copied version


SO in the example above, if 09-01556.A2.12.jpg already exists in c:\mydir\09-01556, then the batch command would copy it as 09-01556.A2.12~1.jpg

I am also looking to set this script running with some kind of user interface where it runs every 5sec or so with some kind of indicator to the user that it is running

Thanks


See More: batch file to copy & increment

Report •


#1
March 14, 2009 at 01:18:19
Quote:
SO in the example above, if 09-01556.A2.12.jpg already exists in c:\mydir\09-01556, then the batch command would copy it as 09-01556.A2.12~1.jpg

dir %name:~0,8%\%* && (
   move %* %name:~0,8%\%~n*~1%~x* ) || (
   move %* %name:~0,8%)

quote:
I am also looking to set this script running with some kind of user interface where it runs every 5sec or so with some kind of indicator to the user that it is running

title "waiting"
ping -n 5 localhost >nul
tile "running"
%0


Report •

#2
March 14, 2009 at 02:01:05
What happened to this thred?

Did my script not work??


Report •

#3
March 14, 2009 at 02:16:58
heh, double post maybe?????

i scroll down and looks for old thread that has not been answered. trying to make every thread at least had a response.
and this thread is one of them.


Report •

Related Solutions

#4
March 14, 2009 at 02:34:42
Reno, I think your right, you answered the old one I answered the new one...

Report •

#5
March 14, 2009 at 06:38:43
yes, my attempt at multitasking diverged into a different thread
:) Thx

Report •


Ask Question