x404.co.uk
http://www.x404.co.uk/forum/

Scripting in Windows
http://www.x404.co.uk/forum/viewtopic.php?f=4&t=1576
Page 1 of 1

Author:  forquare1 [ Wed Jul 01, 2009 3:44 pm ]
Post subject:  Scripting in Windows

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

Author:  AlunD [ Wed Jul 01, 2009 3:56 pm ]
Post subject:  Re: Scripting in Windows

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.

Author:  forquare1 [ Wed Jul 01, 2009 4:23 pm ]
Post subject:  Re: Scripting in Windows

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 :?

Author:  AlunD [ Wed Jul 01, 2009 4:29 pm ]
Post subject:  Re: Scripting in Windows

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.

Author:  forquare1 [ Wed Jul 01, 2009 4:37 pm ]
Post subject:  Re: Scripting in Windows

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...

Author:  big_D [ Wed Jul 01, 2009 5:44 pm ]
Post subject:  Re: Scripting in Windows

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).

Author:  JJW009 [ Wed Jul 01, 2009 6:09 pm ]
Post subject:  Re: Scripting in Windows

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.

Author:  Fogmeister [ Thu Jul 02, 2009 10:13 pm ]
Post subject:  Re: Scripting in Windows

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.

Author:  forquare1 [ Fri Jul 03, 2009 5:52 am ]
Post subject:  Re: Scripting in Windows

Cheers Oli :D

Author:  Xenos [ Sat Jul 04, 2009 11:09 am ]
Post subject:  Re: Scripting in Windows

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?

Author:  forquare1 [ Sat Jul 04, 2009 11:22 am ]
Post subject:  Re: Scripting in Windows

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 :(

Author:  EddArmitage [ Fri Jul 10, 2009 7:38 pm ]
Post subject:  Re: Scripting in Windows

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/