How to speed-up routine renaming, cutting and pasting in Windows XP?
June 9, 2011 5:28 AM   Subscribe

Looking to make routine file renaming, cutting and pasting possible with two clicks in Windows XP.

My work requires that I rename certain files in Windows XP, cut them, and then paste to a different drive. I do this several times daily. I'd like to make this a "two clicks" operation, preferably from the context menu. Here's the operation: (1) rename "example.abc" to "example.xyz"; (2) cut "example.xyz" from "drive a:/" and (3) paste to "drive b:/". I don't need to do this with several files at once, I need to do this individually, on a case-by-case basis. And I'm only renaming the file extensions, not the file names. Ideally, I could use a custom shell extension to simply right click on the file and then click "Rename Extension to .xyz and Paste File to b:/". Is this possible? I do this enough that it's a hassle, and I'd like to remove the possibility of user error from the equation (typos in file extensions lead to issues down the road.)
posted by HerArchitectLover to Computers & Internet (13 answers total) 2 users marked this as a favorite
 
You can do this with some simple vbscript which can be put into your right menu button. Assuming you've not found a better solution, I'll have a stab later on today or tomorrow for you.

Do you want to rename the extension to always the same thing or something you enter each time or is it renamed depending on the original extension?
posted by mr_silver at 5:55 AM on June 9, 2011


Try this: http://www.autohotkey.com/
posted by devnull at 6:48 AM on June 9, 2011 [2 favorites]


Autohotkey will do this. The syntax is a mess and you'll need admin rights but someone may be able to knock up a quick script for you using it.

Best thing about autohotkey is that you can map the action to a keyboard shortcut too.
posted by mr_silver at 6:53 AM on June 9, 2011


Is the new extension consistent with all files? If so you could simply add a vbs to your "sendto" folder (%userprofile%\sendto) with the following code:


On Error Resume Next
Dim objArgs, fso, shortName, newLocation, newExtension

newLocation = "c:\test\"
newExtension = InputBox("What new file extension would you like to use?")

' Check for command line arguments
Set objArgs = WScript.Arguments

Set fso = CreateObject("Scripting.FileSystemObject")

if objArgs.Count <> 0 Then

For intArgs = 0 to objArgs.Count -1
shortName = split(objArgs.Item(intArgs),".")
fso.MoveFile shortName(0) & "." & shortName(1), shortName(0) & "." & newExtension
fso.MoveFile shortName(0) & "." & newExtension, newLocation
Next
End If

objArgs.close
fso.close
posted by samsara at 8:30 AM on June 9, 2011 [1 favorite]


You could also change the newLocation assignment to be similar to newExtension where you'd get an input box asking where to save it (only caveats are it adds an extra step and there's room for typos). I wrote the above script so it could handle single files or multiples (just in case).
posted by samsara at 9:50 AM on June 9, 2011


Response by poster: The renaming, cutting and pasting is consistent each time. It starts as an M2T file, is renamed as an MPG, and it's cut and pasted from the R: drive to the V: drive. It's the only part of my job that requires this behavior, and it's the same every time, without fail.

I'll take a crack at your suggestions tonight. Thanks!
posted by HerArchitectLover at 10:52 PM on June 9, 2011


Response by poster: samsara: The VBS script is great! Is does save me cutting and pasting. Is there any way to eliminate the input box? The new file extension is always the same. Can the script "know" this and do the renaming for me? Thanks for the intro to VBS -- it's my first time playing with it.
posted by HerArchitectLover at 11:10 PM on June 9, 2011


Response by poster: I see now that "VBS script" is like "ATM machine" ...

devnull, mr_silver: Can autohotkey be mapped to the context menu? Can I use it like a vbscript?

samsara: When I changed newLocation="c:\test\" to newLocation="v:\" it stopped working. Any ideas?

Any way for either of these methods to open the folder I pasted the file into to "verify" that the action has been performed?

Thanks again!
posted by HerArchitectLover at 11:44 PM on June 9, 2011


Is there any way to eliminate the input box?

Yep! Just replace the assignment of newExtension at the top of the script with "xyz" instead of InputBox()

When I changed newLocation="c:\test\" to newLocation="v:\" it stopped working. Any ideas?

Hrmm, that's odd. I'll see if I can recreate the issue here...it might be network drive related. You can troubleshoot your version of the script too by placing a single quote in front of "On Error Resume Next." This will comment it out so errors will be displayed if any are encountered:

'On Error Resume Next

I'll post what I find shortly.
posted by samsara at 5:10 AM on June 10, 2011


Best answer: Remove objArgs.close from your script. It's a typo on my part (objArgs isn't closable since it really doesn't open anything, but shouldn't hurt the script's ability to run if its left in...just kicks back an error when On Error Resume Next is commented out)

Double check the destination file does not already exist (this will not overwrite) and your script to make sure its similar to this one...just to make sure there aren't any other typos:

'-------------------------------------------------------
'On Error Resume Next
Dim objArgs, fso, shortName, newLocation, newExtension

newLocation = "v:\"
newExtension = "mpg"

' Check for command line arguments
Set objArgs = WScript.Arguments

Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

if objArgs.Count <> 0 Then

For intArgs = 0 to objArgs.Count -1
shortName = split(objArgs.Item(intArgs),".")
fso.MoveFile shortName(0) & "." & shortName(1), shortName(0) & "." & newExtension
fso.MoveFile shortName(0) & "." & newExtension, newLocation
Next
End If

objShell.Run "explorer.exe " & newLocation

fso.close
'-----------------------------------------------------------------------

You may want to try editing this in Notepad++ to make sure the syntax of your version is good.

Also, AutoHotKey and its cousin AutoIT Script are two VERY useful automation tools to have in your arsenal. For example...with AutoIT. You could record a macro that right-clicks and renames (shift+F10 is your shortcut for rightclicking...never record mouse actions unless its absolutely necessary...do it all via your arrow keys and keyboard shortcuts...ALT+D changes focus to the address bar so you can change the drive and paste.).

Also, to answer your question about the context menu, simply modify the file association of .m2t (in Explorer, go to Tools/Options then select the File Types tab). From there you can add an additional action for that file type in particular. For example...if you wanted to limit the above vbscript to just M2T files, you would add the following action under the Advanced button:

Action:
Rename and Move

Application used to perform action:
wscript "c:\path to my vbs file\myvbsfile.vbs" "%1"
posted by samsara at 5:47 AM on June 10, 2011 [1 favorite]


You'll need the full path to wscript

Application used to perform action:
"%windir%\system32\wscript.exe" "c:\path to my vbs file\myvbsfile.vbs" "%1"
posted by samsara at 5:51 AM on June 10, 2011


Response by poster: Thanks for the thorough answer, samsara. I'm actually looking forward to getting back to my work PC so I can test all this out! I'll post again if I have any issues or questions. This looks like just what I need, though. And thanks for the extra info about AutoHotkey and file associations!
posted by HerArchitectLover at 11:06 AM on June 10, 2011


Absolutely. If I don't respond here feel free to memail me too.

(p.s. Oh, and I just noticed a typo in my AutoIT link...forgot the colon in the url....try here instead)

Good luck!
posted by samsara at 11:10 AM on June 10, 2011


« Older How to open Pages documents on a PC?   |   How long should ADA paperwork take? Newer »
This thread is closed to new comments.