Gzipping several files individually and renaming using datetimestamp
I currently have a batch job that performs many functions. Two of them are below. I was wondering how this can be done in a custom class
mv $TEMPDIR/$FILE $TEMPDIR/$FILEa"_$DATESTAMP.txt"
mv $TEMPDIR/$FILE1 $TEMPDIR/$FILE1a"_$DATESTAMP.txt"
mv $TEMPDIR/$FILE2 $TEMPDIR/$FILE2a"_$DATESTAMP.txt"
mv $TEMPDIR/$FILE3 $TEMPDIR/$FILE3a"_$DATESTAMP.txt"
mv $TEMPDIR/$FILE4 $TEMPDIR/$FILE4a"_$DATESTAMP.txt"
#Gzip files
find $TEMPDIR -type f ! -iname '*gz' -exec gzip '{}' \;
Thank you
Discussion (2)0
Comments
Example with one file for Windows:
Class dc.test [ Abstract ]
{
/// d ##class(dc.test).test()
ClassMethod test()
{
s ts=##class(%PosixTime).LogicalToUnixTime(##class(%PosixTime).CurrentUTCTimeStamp()),
oldName="C:\Tmp\test",
newName=oldName_$$$FormatText("a%1.txt",ts)
s f=##class(%Stream.FileBinary).%New()
d f.LinkToFile(oldName)
s gz=##class(%Stream.FileBinaryGzip).%New()
s gz.Filename=newName
d gz.CopyFromAndSave(f)
d ##class(%File).Delete(oldName)
}
}Hi,
Thanks so much for the quick response. We are actually on Suse Linux and there are multiple(5) files.
Thank you
Lou