Reply to topic  [ 12 posts ] 
Scripting in Windows 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Hi all,

Next week I start a new job. The job is to rename a few thousand files to conform to a naming standard.
I know part of the naming standard will have the creation date, then a hyphen, then the project/file name, plus a load of optional 'flags' (stupid naming convention by the sounds of it).

So, I know I can use a combination of ls, sed, awk and for each loops on a UNIX environment to do most of the work for me...
Can I use these same tools under Windows? And will they work the same (output can be different, but flags/formatting would be annoying if different)?
I think I'll be using some form of Windows XP, and doubt I'll be able to install anything apart from the base set of applications.

Thanks for your help :)
Ben


Wed Jul 01, 2009 3:44 pm
Profile WWW
Site Admin
User avatar

Joined: Fri Apr 24, 2009 6:12 am
Posts: 7011
Location: Wiltshire
Reply with quote
Don't know if its the best way of doing it but I'd use VB / VBA ( in office ) holding the variables in a spreadsheet etc.

_________________
<input type="pickmeup" name="coffee" value="espresso" />


Wed Jul 01, 2009 3:56 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
I don't think I need anything that complex :shock: :shock: :shock:

The way I see it, is something like this:

Code:
pwd=`pwd`
for each in `find $pwd`;
do
    date=`ls -lT $each | awl '{print $9,$6,$5}' | sed 's/ //g'`
    name=$each
    finalname=$date-$name
    mv $each $finalname
done


Not sure if that'll work, not tested it yet, but it should work relatively well...But I've no idea if that would work under Windows :?


Wed Jul 01, 2009 4:23 pm
Profile WWW
Site Admin
User avatar

Joined: Fri Apr 24, 2009 6:12 am
Posts: 7011
Location: Wiltshire
Reply with quote
forquare1 wrote:
I know part of the naming standard will have the creation date, then a hyphen, then the project/file name, plus a load of optional 'flags' .

It was that bit I was thinking about. Not knowing how complex that would be to work out.

_________________
<input type="pickmeup" name="coffee" value="espresso" />


Wed Jul 01, 2009 4:29 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Ahh yes :oops: ...From the limited information I've been told so far, it looks like make of the optional flags won't be used for the majority of the files...So I was thinking about adding them in by hand after...


Wed Jul 01, 2009 4:37 pm
Profile WWW
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
Have a look at Windows PowerShell, an update for XP and part of Vista and Windows 7 (although I think it came as part of SP1 or SP2 with Vista).

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Wed Jul 01, 2009 5:44 pm
Profile ICQ
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:58 pm
Posts: 8767
Location: behind the sofa
Reply with quote
I'm afraid I'd probably use Excel / VBA. Import the detailed file list, and then it's easy to see what you're doing before you hit the "GO!" button.

_________________
jonbwfc's law: "In any forum thread someone will, no matter what the subject, mention Firefly."

When you're feeling too silly for x404, youRwired.net


Wed Jul 01, 2009 6:09 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Have a look at the link in my "Finding files in a batch file" thread.

I did some fairly advanced stuff just using batch files.

Some very nice resources.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Thu Jul 02, 2009 10:13 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Cheers Oli :D


Fri Jul 03, 2009 5:52 am
Profile WWW
Has a life

Joined: Wed May 27, 2009 9:33 pm
Posts: 12
Reply with quote
You can get varieties of all your favourite shell script utilities for windows. I have some of those you've mentioned.

Try http://gnuwin32.sourceforge.net/

Maybe cygwin could be useful too?


Sat Jul 04, 2009 11:09 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
Xenos wrote:
You can get varieties of all your favourite shell script utilities for windows. I have some of those you've mentioned.

Try http://gnuwin32.sourceforge.net/

Maybe cygwin could be useful too?


Thanks Xenos, until Monday I'm not sure if I can install new apps :(


Sat Jul 04, 2009 11:22 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
I would have said cygwin, and then your favourite *nix commands. Pester people for it! A computer without a Bash is a computer that is unhappy.

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Fri Jul 10, 2009 7:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.