| | #1 |
| Senior Warrior Member War Room Member |
Hey techie programming gurus.... Was hoping one of you would chime in here with your wisdom to assist a dumbass warrior... I have about 400 folders with a text file called Final.txt residing in each folder. C:\Folder\birds\Final.txt C:\Folder\cats\Final.txt C:\Folder\dogs\Final.txt C:\Folder\mouse\Final.txt C:\Folder\tiger\Final.txt I need to make a copy of each Final.txt file and rename this file so it correspond to each folder name and have these folders saved in another location. Like this... C:\FolderB\birds\birds-Final.txt C:\FolderB\cats\cats-Final.txt C:\FolderB\dogs\dogs-Final.txt C:\FolderB\mouse\mouse-Final.txt C:\FolderB\tiger\tiger-Final.txt Does anybody know the syntax to use in a .bat dos file to do this? Thanks guys! Frank Bruno |
| |
| | #3 |
| HyperActive Warrior |
Take a look at the "for in do" loop. Since your folder names become the new file names, you can create a variable as a placeholder for each folder and file. You can take this in stages or enter all 400 names at once. It will look something like this . . . Code: @echo off cls echo. echo Copying files now . . . echo. for %a in (birds cats dogs mouse tiger) do copy C:\Folder\%a\Final.txt C:\FolderB\%a\%a-Final.txt echo. echo Done! |
| Exciting comment opportunities on my WF blog: (1) Better money with better marketing (2) Forming strong customer bonds (3) Earn more money with DB marketing (4) Building a revenue and profit model | |
| |
| | #4 |
| Advanced Warrior War Room Member Join Date: 2004 Location: Perth, Australia.
Posts: 724
Thanks: 6
Thanked 184 Times in 136 Posts
|
If you want to move files from one location to another, you could try the MV command instead of COPY in the above example. Take care Bruce |
| |
|
| Bookmarks |
| Tags |
| bat, files, folders, move, syntax |
| |