Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
daviddc114
- Posts: 19
- Joined: 23 Jul 2013 12:45
#1
Post
by daviddc114 » 04 Sep 2013 10:23
I am trying to write a MOVE batch file to move a set of directories with some images in them to another directory that has the same contents in it. However i want to keep the both copies of the images, so i am trying to make the batch file move and rename the files only from A to B.
i have
xcopy C:\Folder\Main C:\Folder\Secondary /e
but i dont know how to add RENAME correctly, i want to rename the files in each directory but not the directories. I want the directories to stay the same and merge together, but the files withing the directories i want to rename so i keep the original files and the copies. Right now it keeps asking me to overwrite or skip which i do not want.
-
ibgumel
- Posts: 1
- Joined: 04 Sep 2013 12:24
#2
Post
by ibgumel » 04 Sep 2013 12:41
hi, i guest this may be will help
firstly copy the files to another directory as you write
xcopy C:\Folder\Main C:\Folder\Secondary /e
then rename the file after changing to the copied directory, copy the files from the copied directory to were you want it to be
cd c:\folder\secondary\e
ren *.extension *. extension
xcopy c:\Folder\Secondary\e C:\Folder\main
hope this will help
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#3
Post
by foxidrive » 04 Sep 2013 20:12
This will add -01 to the end of every file in the "C:\Folder\Main" tree and then merge the folders.
Test it on sample directories first.
Code: Select all
@echo off
for /f "delims=" %%a in (' dir "C:\Folder\Main" /b /s /a-d ') do ren "%%a" "%%~na-01%%~xa"
xcopy "C:\Folder\Main\*.*" "C:\Folder\Secondary\" /e