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

Re: [Clip] global file change

Expand Messages
  • 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 1 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}
      ^!Set %Path%=^%Logs%^%YYYY%\
      ^!Set %YY%=^$StrCopyRight("^%YYYY%";2)$
      ^!Set %Spec%=????^%YY%.txt
      ;^!Info Path=^%Path% Spec=^%Spec%
      ^!Set %OldName%=^$GetFileFirst(^%Path%;^%Spec%)$
      ^!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

      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.