Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: VB script: Rename all files in a folder to a specified prefix

30 Jan 2015   #11

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan

Suggesting different scripting languages are we now, Jimbo?

In that case, the following Command Prompt command appends the string "PRE_" to each filename in the current directory.
for %I in (*) do ren "%I" "PRE_%~nxI"

And even easier to accomplish in Windows PowerShell,
gci | ren -new {"PRE_$_"}

Though, I think Moonsie is more looking forward to fixing his VBScript, rather than reading all about how VBScript is such a bad language compared to blah and blah.

Quote   Quote: Originally Posted by jimbo45 View Post
Another good teaching code language is PYTHON
However, I highly recommend this language^

My System SpecsSystem Spec
30 Jan 2015   #12

Windows 8.1 64-bit

The script accepts 2 (optionally 3) parameters.

The command you entered (RenameFiles.vbs "c:\Users\Richards" sp_train 01.jpg) would be interpreted as 3 parameters, but it doesn't know how to handle the 3rd (01.jpg). It should be 1 or true if you want to prompt for each file, but any non-zero number should work.

Warning: you might not actually want to run this command. I'm not sure it would succeed, but if it does, it will rename the user hive of your registry (ntuser.dat).

If you just want to rename the files without prompting, you would want to enter (at the command prompt, see attached image and make sure you are in the directory in which renamefiles.vbs is located):

RenameFiles.vbs "c:\Users\Richards" sp_train

Keep in mind that this script doesn't care about file extensions. This is going to rename every file with any extension "sp_train" followed by _ and a number followed by the original extension. For example: "sp_train_01.jpg".

If you're just trying to rename some files for yourself occaisionally, you might be better off using a tool like 1-4a Rename. It has a GUI and advanced renaming options.

Attached Images
VB script: Rename all files in a folder to a specified prefix-untitled.png 
My System SpecsSystem Spec

 VB script: Rename all files in a folder to a specified prefix

Thread Tools

Similar help and support threads
Thread Forum
Script to Auto Rename Multiple Files in Windows Explorer
Is there a way to automate the renaming of multiple files in windows explorer which will also add the Julian date at the beginning of each file name. I have a sign-in roster for my employees at work to digitally sign each day when the report to work and again before the depart. I have been...
General Discussion
Temp folder with padlock icon in C:\User folder after try PC rename
I tried to completely rename my pc acct, user profile folder, etc; using this thread: It didn't work. The 1st time I booted, W-7 had created a new acct with beginning user settings (taskbar...
How to script a daily copy of files w/dt being name of archive folder
Hello, I need to figure out a Windows 7 script to copy/archive files which are located in a specific folder. It needs to copy daily to an archive folder, with the script creating the archive folder as MM-DD-YY (being that day's date that is being archived) before it archives the files to that...
General Discussion
Program to monitor folder and rename files?
Hi All, i'm looking for a way to auto rename files with a pre defined prefix and consecutive numbers when they are moved into a folder. I have tried a program called personal rename, I can get the rename function to work but the folder monitoring is giving me issues, not sure if it doesn't work the...
GROD in only one folder, can't delete/move/rename files in it
Hello guys, I've read this forum so many times and I'm usually good at finding solutions on the web by browsing forums and articles but now ...can't fix this :( I hope someone will be able to help me I have a acer aspire 7750G-6634 laptop, 8gb of ram, 2 HDs, i5, windows 7 home (the one that...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:06.
Twitter Facebook Google+