Windows XP: how do I add 00 in front of every file via command prompt?

11,231

If you really want to rename everything:

for %a in (*.*) do ren %a 00%a

If you only want to rename .gif files:

for %a in (*.gif) do ren %a 00%a

If you need to add the prefix to file names with spaces in them put quotes around the %a and 00%a at the end of the line, i.e.

for %a in (*.*) do ren "%a" "00%a"
Share:
11,231

Related videos on Youtube

reyes
Author by

reyes

Updated on September 18, 2022

Comments

  • reyes
    reyes over 1 year

    Windows XP: how do I add 00 in front of every file via command prompt?

    I tried REN * 00*.gif but it doesn't work.

    • victoroux
      victoroux over 12 years
      I know this isn't exactly what you've asked for but there is a program called Bulk Rename Utility that does this and a lot more. I see someone has already answered how to do this via command prompt so you should be set that way :)
  • reyes
    reyes over 12 years
    great! it works!
  • Harry Johnston
    Harry Johnston over 12 years
    For future reference: this works properly on Windows XP but not on Windows 7; one of the files will be double-renamed (so x.gif would become 0000x.gif in this case). The easiest workaround is to create a new directory and use move instead of rename: move %a x\00%a
  • jjxtra
    jjxtra over 11 years
    I'm not seeing the double rename problem on Windows 8, maybe they fixed it
  • ᴍᴀᴛᴛ ʙᴀᴋᴇʀ
    ᴍᴀᴛᴛ ʙᴀᴋᴇʀ about 9 years
    Works great! Now to find the undo option... Doh!
  • cantsay
    cantsay over 7 years
    @HarryJohnston works fine for me (Windows 7 Pro SP1 x64)