Open Side Menu Go to the Top

10-03-2012 , 01:49 PM
(I don't see a lot of "how do I" posts here so apologies if it's not an appropriate question for this forum.)

So, I'm wondering if there is an easy way for a novice to script windows to rename a list of files in a directory (and sub directories)? I googled, and looking at the results I think the answer is "no", but thought I'd ask here.

I am a basic computer user, probably about a 4 out of 10 excel user. I understand some basic Excel Macro stuff through using the record macro function. I actually had a class on VBA in grad school as well, so I have at least been exposed to some of the scripting basics.

My goal is to take a directory full of files and subfolders, all .xls or .xlsx files. Each is named something completely different, and what I'd like to do is change the name of the file from "Dept 1 Budget.xlsx" to "Dept 1 Budget Working.xlsx", then repeat that for all files in the directory.

What I don't know is if it's even possible to script in basic Windows? This would be on a work computer so I can't install any new software without going through IT.

If anyone has any advice, much appreciated Thanks for the help.
how to: basic windows scripting? Quote
how to: basic windows scripting?
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
how to: basic windows scripting?
10-03-2012 , 03:35 PM
You could do this with C++, using the std::rename
http://www.cplusplus.com/reference/c...cstdio/rename/

Create a loop that will go through the directory, taking the current name by placing it into a string and attaching " Working" to the string and then use the rename function with that string.

I've never done this btw but it doesn't look that hard.
how to: basic windows scripting? Quote
10-03-2012 , 03:41 PM
1. https://www.google.com/search?q=wind...nd+line+rename
2. http://www.microsoft.com/resources/d....mspx?mfr=true

but i couldn't figure out how to use the * wildcards
i tried this, but it didnt work
Code:
ren *.* *Working.*
alternatively, AHK works as exptected
Code:
FileMove, *.*, * Working.*
how to: basic windows scripting? Quote
10-03-2012 , 04:39 PM
You probably want Windows PowerShell

http://stackoverflow.com/questions/1...ing-powershell
how to: basic windows scripting? Quote
10-04-2012 , 09:41 AM
Quote:
Originally Posted by jawhoo
What I don't know is if it's even possible to script in basic Windows? This would be on a work computer so I can't install any new software without going through IT.

If anyone has any advice, much appreciated Thanks for the help.

Already installed on every windows machine and able to do your job:

batch files. http://commandwindows.com/
vbscript. http://en.wikipedia.org/wiki/VBScrip...ile_operations
jscript (javascript)

I would write a vbscript file (vbs).
how to: basic windows scripting? Quote
10-04-2012 , 10:44 AM
Thanks for the leads all, going to dig into them starting with vbscript. I may or may not be able to figure it out, but it is significantly more interesting than right-clicking on 800 files.
how to: basic windows scripting? Quote
10-04-2012 , 12:43 PM
figured it out

with help from here:
http://superuser.com/questions/16007...3rd-party-tool

1. open up a command prompt in the folder you want to rename. you can do that by holding down SHIFT and right clicking on the folder, then selecting "Open Command Window Here" (win7)

2. type the following two commands:

Quote:
dir /B filelist.txt
for /f "tokens=1,2 delims=." %i in (filelist.txt) DO ren "%i.%j" "%i_working.%j"
and
according to here if you want to make a batch file out of it, you need to double up the percent signs %%
how to: basic windows scripting? Quote
10-04-2012 , 10:06 PM
Easy solution http://www.bulkrenameutility.co.uk/Main_Intro.php

Or you could muck around with reg expressions. Powershell is a good start for windows scripting.
how to: basic windows scripting? Quote
10-05-2012 , 01:08 PM
Regex is unnecessary for this. Here's the powershell

Code:
Get-ChildItem -path "c:\tst" -Include *.xls,*.xlsx -Recurse| Rename-Item -NewName {$_.Basename + " Working" + $_.Extension}
Get-Childitem is same as 'dir'. We're only looking for xls & xlsx and we're recursing
the "|" (pipe) passes the items found by Get-ChildItem to the next command (in this case Rename-Item) one at a time

Rename-Item is setting the newname equal to the BaseName + " Working" + extension
The $_ variable is called the "pipeline" variable and refers to the current item we're working with. So we're essentially looping through the list returned by Get-ChildItem and each time it loops $_ refers to a single file
how to: basic windows scripting? Quote
10-06-2012 , 07:18 PM
You should get a hold of Python. This kind of thing is ridiculously easy. It is free too.
how to: basic windows scripting? Quote
how to: basic windows scripting?
$25m Guaranteed WPM on CoinPoker
Join the action now
Daily Rewards • Splash Pots • CoinRaces
how to: basic windows scripting?

      
m