File Renaming

I have a folder with sub-folders all named with _XX in the last three characters. I would like to have a batch program that removes these last three charaters.
scsoilAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GCD1Commented:
http://www.skyjuicesoftware.com/software/ffr_info.html

This program is a batch folder renaming suite that will allow you to remove characters in a batch process.
0
97WideGlideCommented:
Check out this link - it has several freeware solutions you can pick from.

http://www.snapfiles.com/Freeware/system/fwfilerename.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PotentisFrogCommented:
Save the following as, say, RemXX.vbs.  Place the vbs file in the parent folder and run it. It will ask if you want to add _XX or remove it.

It only acts on the immediate subfolder level.  You could alter it to be recursive if you want it to act on all sub-subfolders.
call main()
 
sub main()
dim startFolder, thisFolder, subFolders, cFolder, fso, fName
dim askResult
askResult = msgbox("Add _XX suffix?" & vbNewLine & vbNewLine & "Click 'Yes' to add suffix." & vbNewLine & "Click 'No' to remove existing _XX suffix.",3)
'msgbox "return: " & cstr(askResult)
 
if askResult = 2 then
	exit sub
elseif askResult = 6 then
	doAdd = true
else
	doAdd = false
end if
set fso = CreateObject("scripting.filesystemobject")
set startFolder = fso.GetFolder(".")
'msgbox startFolder.name
set subFolders = startFolder.SubFolders
for each thisFolder in subFolders
	fName = thisFolder.name
	'msgbox fName
	if doAdd then
		fName = fName & "_XX"
		thisFolder.name = fName
	else
		if right(fName, 3) = "_XX" then
			fName = left(fName, len(fName)-3)
			thisFolder.name = fName
		end if
	end if
next
end sub

Open in new window

0
AmazingTechCommented:
This will only rename folders with has the 3rd last character as "_".

Change the set folder= to your base folder.
SETLOCAL ENABLEDELAYEDEXPANSION
Set Folder=C:\Files
for /f %%a in ('dir /ad /b "%Folder%"') do (
    Set Subfolder=%%a
    IF "!SubFolder:~-3,1!" == "_" REN "%Folder%\%%a" "!SubFolder:~0,-3!"
)

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.