I'd like to create a batch file under windows to move files with specific file names. I'd like to move all the files with txt extension and filename starting with "HH", and moving them only from root, sub directories excluded. And if a file with the same name is already exist in the destination directory I'd like to auto rename files instead of overwriting. Is it possible to do?
Asked
Active
Viewed 2,826 times
1
-
What do you want them to be auto renamed to? Also, could you give us an example root and destination directory to work with as an example? – UnknownOctopus Jul 20 '15 at 00:16
-
It could be anything, I thought about something similar like this: file(1) file(2) etc. – sasieightynine Jul 20 '15 at 00:17
-
There are two source directories and one destination directory, source1 is a dir from another PC in the network and source2 is a local directory, and the destination would be source2\tmp, move the files from source1+2 root to source2\tmp. Source1: \\PC\VMShared Source2: C:\Destination\HH Destination: C:\Destination\HH\tmp – sasieightynine Jul 20 '15 at 00:22
1 Answers
2
You can simply use:
move c:\HH*.txt destination_directory

clusterdude
- 616
- 3
- 16
-
xcopy is another option, but really you should design your command to do something like add a timestamp to the end of the name. I'm not sure if there's a way to do this in DOS...that would require more research...but it would be quite easy to do that with a script written in something like Python. – clusterdude Jul 20 '15 at 00:24
-
Adding a timestamp to a filename: https://stackoverflow.com/questions/1064557/creating-a-file-name-as-a-timestamp-in-a-batch-job – clusterdude Jul 20 '15 at 00:27
-
-