Spat's WebLog (Steve Patrick)

When things go wrong...

Been away for a bit..

Been away for a bit..

  • Comments 3

I havent posted anything of real interest  (IMO ) in a while, mainly because I have been really really busy.  Basically on vacation for 3.5 weeks, my wife and I went to Rome for the first time. What an amazing place - so much history and architecture ( I originally wanted  to  go to school to be an architect, kinda like George Costanza ) .

I do have a number of posts I need to get done, but for now I am busy catching up at work.

One thing I did have to do was go thru all my pictures I took on vacation and upload them for family\friends to see.  Every other night while we were at the hotel, I would try to download all the images from the camera and rename them to something useful, so I could recall what the photo was of and where I was when I took it.

So i ended up with names like "outside the pantheon next to the fountain.jpg"

Well when I converted them all to a big HTML page via breezebrowser and then tried to upload it all - it complained about all the spaces. Gah. Time to replace the space with an underscore for a bajillion files.

So here was a quickie way to fix that - ( guess Ill give some technical value to this post )

All the files are in one giant directory:

dir /b > files.txt
So then you have a text file something like this:

victor emmanuel monument nighttime .jpg
victor emmanuel monument cake view.jpg

simple vbscript to replace all spaces with underscores

sFile = WScript.Arguments(0)
sNoSpaceFile = replace(sFile," ","_")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "D:\Documents and Settings\steve\Desktop\New Folder\" & sFile , "D:\Documents and Settings\steve\Desktop\New Folder\" & sNoSpaceFile

 

A for loop to process the files:

D:\trip\HTML>for /f "delims=" %a in (files.txt) do space.vbs "%a"


done!

 spat


 

Leave a Comment
  • Please add 7 and 5 and type the answer here:
  • Post
  • A few weeks ago I would have used a similar solution. But then I dicovered Windows Powershell and now I would do:

    get-childitem *.jpg | rename-item -NewName { $_.Name -replace " ","_" }

    :-)

  • Ahh man, that's something Ive been playing with but old habits die hard. I need to force myself to use PS,  instead if falling back to quickie VB's... ( if I ever really want to really learn PS that is )


    thx!
    spat
  • cute.  reaaaal cute.
Page 1 of 1 (3 items)