Thursday, July 22, 2010

Bats and files

Recording here for future reference how to write a batch file to rename a bunch of XML files in Windows. Instructions by my husband, delivered in chat from his holiday, so big kudos to my lovely Heikki :)
  1. Export the file list to a csv file: dir /b *.xml > list.csv.
  2. Open list.csv in Excel.
  3. Copy the contents of column A to column B.
  4. Find and replace in column B as necessary (for me, replace - with _).
  5. Insert a column before A.
  6. Fill all cells of the new column A with the word ren.
  7. Select all and paste to Notepad. Each line should now read ren oldfilename newfilename. There is whitespace in between, this is normal.
  8. Save Notepad file as rename.bat. You now have a batch file.
  9. Run the batch file: enter rename.bat on the command line.
And voilĂ ! Your files are renamed.

(Yes, this is a big deal for me. Yeah, I'm not too knowledgeable about computery stuff. But I'm learning :)

No comments:

Post a Comment