Skip to content

07: ManFiles. a command line file handling program with many features.

Michael Ekdal edited this page Sep 1, 2023 · 16 revisions

ManFiles

The program ManFiles is a command line utility program with many features.

The parameters and switches in ManFiles

-parfile
The name prefix of the parameter file (default is ManFiles).
The file must end with .par
In the default case, files named ManFiles01.par, ManFiles02.par and so on will be found.
The files must reside in the current directory or the directory indicated by -pardir.
NOTE: Used in a par file -sdir and -tdir can contain maximum one blank in the string.
NOTE: Used in a par file no single or double quotes are allowed anywhere in the file.
NOTE: Spaces can be substituted with a ? if more than one space are needed.
-pardir
The name of the -parfile directory, like "-pardir c:\Temp" (optional)
-sdir
The name of the source directory, like "-sdir c:\source"
-tdir
The name of the target directory, like "-tdir c:\target"
-adir
The name of the archive directory, like "-adir c:\archive"
-sub
The subdirectories are searched.(default)
-nosub
The subdirectories are NOT searched.
-copy
Copy the files
-move
Move the files
-del
All selected files are deleted from the source directory!
-nodel
No files are deleted. (default)
-list
The selected files are listed.(default)
-nolist
The selected files are NOT listed.
-log
Write to specific log file. like "-log c:\logg.txt"
-run
Live, no simulation
-norun
Simulation. No copies, moves or deletions are made (default)
-ded
Empty sub-directories are deleted from the source directory.
-noded
No delete of empty sub-directories. (default)
-repl
Replace target files. (default)
-norepl
Do NOT Replace target file.
-nrunq
Used with -norepl to create a new unique file on target.
-append
Append an existing target file
-asuf
Add a new suffix to the source file, like "-asuf transfered"
-rsuf
remove the suffix of the source file, like "-rsuf transfered". Use "-rsuf ." to remove any suffix
-nfile
Name of the new file. Used with append to merge a number of related files.
-unique
The moved or copied file is sufixed with the unique string _YYYYMMDDHHMMSS. like (_20100111113539)
-flat
Files are copied or moved to the -sdir without the original directory structure.
-noflat
Files are copied or moved to the -sdir with the original directory structure (default)
-suf
(include) a file suffix to look for. like "-suf .log". To use more -suf strings, separate them with a semicolon, like stra;strb
-pref
(include) a file prefix to look for. like "-pref Z". To use more -pref strings, separate them with a semicolon like stra;strb;strc
-pos
(include) a string in the file name to look for. as "-pos per". To use more strings, separate them with a semicolon like stra;strb
-inpath
(include) a string in the path name. like "-inpath INV". To use more -inpath strings, separate them with a semicolon like stra;strb
-expath
(exclude) string in the path name. like "-expath INV". To use more -expath strings, separate them with a semicolon like stra;strb
-exfile
(exclude) string in the file name. like "-exfile TEMP01". To use more -exfile strings, separate them with a semicolon like flda;fldb
-fsize
Select files from the size (Bytes).
like -fsize 10737418240
-tsize
Select files to the size (Bytes).
like -tsize 10737418240
-fdat
Select files from the date it was last changed.
like -fdat 20181101000000
-tdat
Select files to the date it was last changed. like -tdat 20181205140000
-hou
Hours since file last changed. like "-hou 48" (default=0)
-min
Minutes since file last changed. like "-min 8" (default=0)
-sec
Seconds since file last changed. like "-sec 30" (default=0)
-nonewh
Select files older than the -hou value (default)
-newh
Select files newer than the -hou value
-sn
Show short file name when list of files.
-nosn
Show long file name when list of files. (default)
-?
This help text are shown.
-help
This help text are shown.
-set
Shows the program settings.
-scan
The string that is searched for inside the files. It must be a single string with no blanks.
-cmd1
The command part1 to use on files.
i.e. "print /d:\ptp165\PBEdicom" (The selected filename is used as a parameter to the command)
-cmd2
The command part2 to use on files.
-countc
Shows the number of children in each traversed directory.
-jvakt
A switch to enable a report OK or ERR to Jvakt. The default is no reporting to Jvakt. The file Jvakt.properties must be provided -id
Used as identifier in the Jvakt monitoring system. This is mandatory if the -jvakt switch is used.
-config
The directory where to find the Jvakt.properties file. Like "-config c:\Temp". Optional. The Default is the current directory.
-loop
Executes every second in a never ending loop. No loop is the default value.
-sleep In seconds. Used with -loop to sleep between checks. The default is one second.

Comments:
Errorlevel is set to the number of found files. Max value is 255 though.

Examples

Move files from -sdir to -tdir The text ptp050 must occur inside the file. The files must end with -xml.

java -cp C:\JavaSrc Jvakt.ManFiles -sdir c:\temp -suf .xml -move -list -tdir C:\tmp -run -scan ptp050 -nosub

Move files from -sdir to -tdir. File file change date is in the 2015 intervall. The program is looping.

java -cp C:\JavaSrc Jvakt.ManFiles -sdir \share\in -list -nosub -fdat 20150101000000 -tdat 20151231999999 -tdir N:\out\2015 -move -run -loop

ManFile is executing the rows inside the parameter file Copy2fs.par and reporting the status to the Jvakt server.

java -cp c:\JavaSrc\ Jvakt.ManFiles -parfile Copy2fs.par -jvakt -id PROD-Copy2fs

ManFile is executing the rows inside the parameter file To-From.par in a never ending loop.

C:\Java\jdk\bin\java -cp C:\JavaSrc Jvakt.ManFiles -parfile To-From -loop
Beginning of To-From.par file
# Comments
-run -move -suf .txt -pos EX2_ -list -nosub -sdir E:\ToY -tdir \fs\FromX -adir E:\Copies
-run -move -suf .txt -pos EX2_ -list -nosub -sdir \fs\ToX -tdir E:\FromY
End of To-From.par file

ManFile is moving files depending on content in the files.

java -cp c:\JavaSrc\ Jvakt.ManFiles -run -move -nosub -sdir \fs\IN -Pos Totalin -suf .txt -tdir \fs\IN\T2 -scan FileContent -nosub

ManFile is checking for old files.

java.exe -cp C:\JavaSrc Jvakt.ManFiles -nosub -pre SAP_ -suf .txt -sdir E:\Integrations\Out -min 30 -nolist > c:\tmp\Check_Folders.txt
IF %ERRORLEVEL% EQU 0 (
java.exe -cp c:\JavaSrc Jvakt.RptToJv -host jvhost -id PROD_Files_from_APP -ok -body "No files from APP in queue"
) else (
java.exe -cp c:\JavaSrc Jvakt.RptToJv -host jvhost -id PROD_Files_from_APP -err -body "Files from APP in queue"
)

Clone this wiki locally