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

Re: global file change

Expand Messages
  • Sheri
    ... Here s a clip that should do it: H= Do Logs ^!Close C: dologs.bat Discard ^!Menu File/New ^!Insert ^$GetDosOutput(dir /b C: logs *.txt /s)$ ^!If
    Message 1 of 4 , Sep 15, 2004
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "chsulka" <dti@c...> wrote:
      > After using NTP for 10 years it's time I learned the CLIP
      > function. I think I saw something in the past that would do
      > this, but I cannot locate the reference. What I need to do:
      > I have folders with daily log files saved as LOGS\1994\010194.TXT
      > where 010194 is the January 1 entry for the year 1994 (DDMMYY).
      > I have years and years of countless files saved this way. I
      > need to change all the files to the proper filing format, which
      > would be 19940101 (year, month, day, YYYYMMDD). Isn't there
      > a clip out there that makes global changes like this? Thanks.
      >
      > Charles Sulka

      Here's a clip that should do it:

      H="Do Logs"
      ^!Close "C:\dologs.bat" Discard
      ^!Menu File/New
      ^!Insert ^$GetDosOutput(dir /b C:\logs\*.txt /s)$
      ^!If ^$GetTextSize$ > 0 Next ELSE End
      ;create a copy or move command for each .txt line
      ^!Set %orig%="{C:\\logs\\}{\d\d\d\d}\\{\d\d\d\d}{\d\d}{.txt}"
      ;the variable %orig% is used just to avoid a long line
      ^!Replace "^%orig%" >> "copy & \1\2\3.log" ATIWRS
      ^!Save As "C:\dologs.bat"
      ^!Clearvariable %orig%
      ^!Continue Do you want to run this batch now?
      ^!Menu File/New
      ^!Insert ^$GetDosOutput(C:\dologs.bat)$
      ^!Info All done.
      ;end of clip
    • Don Daugherty
      ... Try this Change DDMMYY to YYYYMMDD ^!Set %Logs%= c: LOGS ^!Set %YYYY%=^?{Enter oldest year (YYYY), e.g., 1994} ... ^!Set %Path%=^%Logs%^%YYYY% ^!Set
      Message 2 of 4 , Sep 16, 2004
      • 0 Attachment
        >What I need to do:
        > I have folders with daily log files saved as LOGS\1994\010194.TXT
        > where 010194 is the January 1 entry for the year 1994 (DDMMYY).
        >I need to change all the files to the proper filing format, which
        > would be 19940101 (year, month, day, YYYYMMDD).

        Try this

        Change DDMMYY to YYYYMMDD
        ^!Set %Logs%="c:\LOGS\"
        ^!Set %YYYY%=^?{Enter oldest year (YYYY), e.g., 1994}
        :FolderLoop
        ^!Set %Path%=^%Logs%^%YYYY%\
        ^!Set %YY%=^$StrCopyRight("^%YYYY%";2)$
        ^!Set %Spec%=????^%YY%.txt
        ;^!Info Path=^%Path% Spec=^%Spec%
        ^!Set %OldName%=^$GetFileFirst(^%Path%;^%Spec%)$
        :FileLoop
        ^!Set %DD%=^$StrCopy("^%OldName%";14;2)$
        ^!Set %MM%=^$StrCopy("^%OldName%";16;2)$
        ;^!Info DD=^%DD% MM=^%MM%
        ^!Set %NewName%=^%Path%^%YYYY%^%MM%^%DD%.txt
        ^!RenameFile "^%OldName%" "^%NewName%"
        ;^!Info !RenameFile "^%OldName%" "^%NewName%"
        ^!Set %OldName%=^$GetFileNext$
        ^!If ^%OldName%="" Next Else FileLoop
        ^!Inc %YYYY%
        ^!If ^%YYYY%<=2004 FolderLoop
        ;End FolderLoop
        :End

        Note that the clip assumes that \LOGS is in the root of the c: drive. Edit
        this as needed. (Probably ought to make a backup copy of LOGS and all it's
        sub-folders before trying out the clip.)
      Your message has been successfully submitted and would be delivered to recipients shortly.