Solved Copy and Renaming a file

September 20, 2013 at 17:17:50
Specs: Windows XP
I have looked all over the internet for examples. I am trying to copy two separate .txt files from one directory to the current directory and rename them file1.bus and file2.bus using only one command. Can anyone please help?

See More: Copy and Renaming a file

Report •

#1
September 21, 2013 at 02:21:04
✔ Best Answer
Generally I don't think it can be done. You can copy one file from another directory to the current directory and rename it with one command:

copy path to file\filename.txt file1.bus

Or you can copy more than one file using wildcards but you can't rename them with the same command:

copy path to files\*.txt *.bus

(That will copy all the txt files in that directory to the current directory and change their extension to bus but won't change the file name.)

In a special case where the files are fortuitously named you could do it. For example suppose the txt files were named abcd1.txt and efgh2.txt (or any name as long as the fifth place was a 1 and 2 respectively) you could use:

copy path to files\*.txt file?.bus

As far as I know the above is the only way to do it using standard command prompt/dos commands and using only one command.



Report •

#2
September 21, 2013 at 05:17:27
if you want one line you could use a &&

http://ss64.com/nt/syntax-condition...

command one && command two

::mike


Report •
Related Solutions


Ask Question