Loading ...
Sorry, an error occurred while loading the content.
 

RE: [Clip] Re: Batch rename of files

Expand Messages
  • Pete Turner
    G day Jeff, Have you considered a file renaming utility? 1-4a Rename is pretty powerful, freeeware, and can be found at http://www.1-4a.com/rename/ . It d be
    Message 1 of 6 , Feb 28, 2007
      G'day Jeff,

      Have you considered a file renaming utility? 1-4a Rename is pretty
      powerful, freeeware, and can be found at http://www.1-4a.com/rename/ .
      It'd be ideal for what you want to do. Horses for courses.

      (I have no connection with 1-4a Rename other than as a satisfied user.)


      Pete



      > -----Original Message-----
      > From: ntb-clips@yahoogroups.com
      > [mailto:ntb-clips@yahoogroups.com] On Behalf Of Jeff Scism
      > Sent: Thursday, 1 March 2007 09:14
      > To: ntb-clips@yahoogroups.com
      > Subject: Re: [Clip] Re: Batch rename of files
      >
      > I too am very sad about Jody's passing, whenever I ran into
      > problems, he
      > was right there to help out.
      >
      > Miss him already.
      >
      >
      > The file names are currently : bios-johnhsmith.txt or (.htm) and the
      > target file name is smith-john-h.htm in the new S subdirectory, so
      > would save as 'bios\s\smith-john-h.htm' from the source directory.
      >
      > The surname's initial letter determines which directory
      > within the bios
      > directory is the target.
      >
      > (Since I have less than 1200 which are botched I can manually
      > rename...but that will be a slower process.)
      >
      > If I can have a search/replace that looks for the file names which
      > contain "bios-" and "obits-" and replaces the part of the
      > file name with
      > "", then It would save a lot of time.
      >
      >
      > Jeff
      >
      >
      > Sheri wrote:
      > >
      > > --- In ntb-clips@yahoogroups.com
      > <mailto:ntb-clips%40yahoogroups.com>,
      > > "Jeff Scism" <Scismgenie@...> wrote:
      > > >
      > > >
      > > > (Using STD 5.1)
      > > >
      > > > Looking for a way to remove pre-pends from file names
      > > > in directories.
      > > >
      > > > I have a scad of files that are pre-pended with bios-
      > > > or obit- in each filename, the previous site manager
      > > > had ALL files in one flat directory, and separated
      > > > them with name prepends. I am restructuring to
      > > > appropriate file directories, and want to remove the
      > > > prepends.
      > > >
      > > > The issue is that all have a dash as the last character
      > > > I want to remove, and there are several which have a
      > > > dash as well that do not need changing.
      > > >
      > > > Jeff
      > >
      > > Jeff,
      > >
      > > The way to do it is with a bat file, which can be created
      > and executed
      > > inside NoteTab. What is the file extension on these files,
      > .txt? What
      > > is an example of a before and after file name?
      > >
      > > Very sad about Jody.
      > >
      > > Regards,
      > > Sheri
      > >
      > >
      >
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      > --------------------~-->
      > See what's inside the new Yahoo! Groups email.
      > http://us.click.yahoo.com/0It09A/bOaOAA/yQLSAA/dkFolB/TM
      > --------------------------------------------------------------
      > ------~->
      >
      > Fookes Software: http://www.fookes.com
      > Fookes Software Mailing Lists: http://www.fookes.com/maillist.htm
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
    • Sheri
      Hi Jeff, The following clip will rename and move such files into bios aa or obits aa. If you want to edit the batch file before it is run, you can fix the file
      Message 2 of 6 , Mar 1, 2007
        Hi Jeff,

        The following clip will rename and move such files into bios\aa or
        obits\aa.

        If you want to edit the batch file before it is run, you can fix the
        file name and put the correct subdir instead of aa. However, before
        you run the bat file, all those subdirs would need to exist (else add
        creation of a-z subdirs of bios and obits to the bat file before
        running. You will see where bios\, obits\, bios\aa and obits\aa or
        created in the bat file.) You should have the bat file as the current
        document and rerun the clip when you are ready to process the bat
        file. It will ask if you want to run this bat file. If you don't run
        it, it will get recreated, and any manual edits you did will be lost.
        So perhaps you should also back up the bat file if you edit it.

        When the clip runs the bat file it creates a temporary document
        showing a log of what happened. Errors will show as "The system cannot
        find the file specified." or "The system cannot find the path specified."

        If you don't want to edit the bat file, as I said, they will all go
        into aa subdirs and you can mess with them there.

        The bat file only acts on htm and txt files whose names begin with
        bios- or obits-. It is case insensitive, so should work also on BIOS-
        or BiOs-, etc.

        The files retain the same extension (txt or htm) they had before
        moving/renaming.

        Hope it works out, you should probably make a backup of the directory
        before using (just in case). Please be sure to unwrap long lines, I
        tried to indicate them in comments.

        Regards,
        Sheri

        ;2007-02-28 Sheri
        ^!Set %myfile%="^$GetDocName$"
        ^!IfDiff "^$GetExt("^%myfile%")$" ".bat" Skip_1
        ^!Skip Run ^%myfile% ?
        ^!Goto Testbatfile
        ^!Goto Runmybat
        :Testbatfile
        ^!Set %mydir%="^?{(T=D) Browse to Dir=^%mydir%}"
        ^!IfFileExist "^%mydir%RenDashFiles.bat" Next ELSE Createbatfile
        ;long line follows
        ^!Continue Existing ^%mydir%RenDashFiles.bat will be deleted and
        recreated, cancel now if you wish. OK continues.
        ;end long line
        ^!Close "^%mydir%RenDashFiles.bat" discard
        ^!DeleteFile "^%mydir%RenDashFiles.bat"
        :Createbatfile
        ^!Toolbar New Document
        ^!ChDir ^%mydir%
        ^!MkDir bios\
        ^!MkDir obits\
        ^!MkDir bios\aa\
        ^!MkDir obits\aa\
        ^!InsertText ^$GetDosOutput(Dir *.txt /b)$
        ^!Jump Doc_End
        ^!InsertText ^$GetDosOutput(Dir *.htm /b)$
        ;long line follows
        ^!Replace "^(?!(?:bios|obits)).+?\r\n" >> "" RAWS
        ^!IfTrue ^$IsEmpty(^$GetText$)$ Next Else Skip_3
        ^!Prompt No Files to Move/Rename!
        ^!Close Discard
        ^!Goto End
        ;begin long line
        ^!Replace "^(bios|obits)\-(.+?)(\.(?:htm|txt))$" >> "$2$3 \>\> MOVE
        \x22$1-$2$3\x22 \x22$1\\AA\\$2$3\x22" RAWIS
        ;end long line
        ^!Select All
        ^!InsertText ^$StrSort("^$GetText$";No;Yes;No)$
        ^!Replace ".+?\>\> (?=MOVE)" >> "" RAWS
        ^!SetWordWrap Off
        ^!Jump Doc_Start
        ^!InsertText cd /D "^%mydir%"
        ^!Info check
        ^!Save As "^%mydir%RenDashFiles.bat"
        ^!Set %myfile%="^$GetDocName$"
        ;begin long line
        ^!Skip Do you want to now run ^%myfile% ? Select No if you wish to
        edit the file names.
        ;end long line
        ^!Goto end
        :Runmybat
        ^!Set %myext%="^$GetExt("^%myfile%")$"
        ^!IfSame "^%myext%" ".bat" Next Else Error
        ^!IfTrue ^$IsModified$ Next Else Skip_1
        ^!Save
        ^!Chdir "^$GetPath("^%myfile%")$"
        ^!Set %batfile%="^$GetName("^%myfile%")$"
        ^!Set %tempvar%="^$GetOutput(cmd /c ^%batfile%>keeprenoutput 2<&1)$"
        ^!Toolbar New Document
        ^!SetWordWrap Off
        ^!InsertText ^$GetFileText(^%mydir%keeprenoutput)$
        ;begin long line
        ^!Find "The system cannot find [^\r\n]+" RWS
        ^!Prompt This is a log of what occurred. Files not moved (if any) are
        followed by the text "The system cannot find the file specified" or
        "The system cannot find the path specified." You will need to
        troubleshoot such files. The first such error (if any) is highlighted.
        ;end long line
        ^!Goto End
        :Error
        ^!Prompt Error: Current document is not a bat file
        ;end of clip



        --- In ntb-clips@yahoogroups.com, Jeff Scism <Scismgenie@...> wrote:
        >
        >
        > I too am very sad about Jody's passing, whenever I ran
        > into problems, he was right there to help out.
        >
        > Miss him already.
        >
        >
        > The file names are currently : bios-johnhsmith.txt or
        > (.htm) and the target file name is smith-john-h.htm
        > in the new S subdirectory, so would save as
        > 'bios\s\smith-john-h.htm' from the source directory.
        >
        > The surname's initial letter determines which
        > directory within the bios directory is the target.
        >
        > (Since I have less than 1200 which are botched I can
        > manually rename...but that will be a slower process.)
        >
        > If I can have a search/replace that looks for the file
        > names which contain "bios-" and "obits-" and replaces
        > the part of the file name with "", then It would save a
        > lot of time.

        >
        >
        > Jeff
        >
        >
        > Sheri wrote:
        > >
        > > --- In ntb-clips@yahoogroups.com
        <mailto:ntb-clips%40yahoogroups.com>,
        > > "Jeff Scism" <Scismgenie@> wrote:
        > > >
        > > >
        > > > (Using STD 5.1)
        > > >
        > > > Looking for a way to remove pre-pends from file names
        > > > in directories.
        > > >
        > > > I have a scad of files that are pre-pended with bios-
        > > > or obit- in each filename, the previous site manager
        > > > had ALL files in one flat directory, and separated
        > > > them with name prepends. I am restructuring to
        > > > appropriate file directories, and want to remove the
        > > > prepends.
        > > >
        > > > The issue is that all have a dash as the last character
        > > > I want to remove, and there are several which have a
        > > > dash as well that do not need changing.
        > > >
        > > > Jeff
        > >
        > > Jeff,
        > >
        > > The way to do it is with a bat file, which can be
        > > created and executed inside NoteTab. What is the file
        > > extension on these files, .txt? What is an example of a
        > > before and after file name?
        > >
        > > Very sad about Jody.
        > >
        > > Regards, Sheri
        > >

        >
      • Sheri
        Something is amiss with group messages, I ve not received any of several recent messages. If this comes through and you re looking for replies, please check at
        Message 3 of 6 , Mar 1, 2007
          Something is amiss with group messages, I've not received any of several
          recent messages.

          If this comes through and you're looking for replies, please check at
          http://tech.groups.yahoo.com/group/ntb-clips

          Regards,
          Sheri
        Your message has been successfully submitted and would be delivered to recipients shortly.