|
Answer» Hi,
I would like to be able to change the file extension on several files at once, but the batch file needs to be in another folder to those files being changed.
For example the files are CONTAINED in C:\Aa\temp, and the batch file needs to be in the root of C. The process will be to change the extension from txt to xml, move the files and then change them back to txt. The movement of the files is a separate process and need not be incorporated into a batch file. Anyone any ideas?
Thanks
yes - 2 ways 1]
Code: [Select]cd /d C:\Aa\temp c:\batchfilename 2] REWRITE your batchfile to accept the name of a directory as a parameter and reference your files using the parameter as the path
1] is simplest and it will work on any drive / directoryHi,
Thanks for your reply. sorry I'm not sure what you mean about creating a batch file to accept parameters. could you please explain a little further.
Many thanks
It would be a lot easier with an example ... could you PASTE the CONTENTS of your batch file and I will show you how to amend itHi,
Here it is
echo off RENAME C:\Aa\Test\ *.xml *.sst
Thanksok then,using your batch, Ill colour code my changes
echo off REM %1 is a special variable, the first parameter passed REM test if any parameter was supplied If [%1]==[] Goto Error REM OK, the ~ char in %~1 means strip off the quotes RENAME "%~1\*.xml" *.sst GoTo :EOF REM no param, show error message :Error Echo Supply a directory name on the command LINE, eg REM %0 is the name of the batchfile as entered on the command line Echo %0 "My Folder" Hi,
Thanks for your reply. I'll give it a try. How would I call the batch and put the variable at the command line?
Thanks Good luck with it Suppose we called the batchfile RenameXML.bat
then the commandline would be
RenameXML C:\Aa\Test
assuming you were in the root, if not then
C:\RenameXML C:\Aa\Test
|