Batch file with CPDF to multi files - batch-file

i am using this command in cmd with cpdf.
cpdf -split a.pdf -o page %%%pdf
but I wanted to use it for a pdf list in a directory.
ie you need a batch script that runs on all pdf files in the directory and the cpdf split command is applied to each file dividing by one per sheet.
example, transform the files:
a.pdf
b.pdf
c.pdf
and more ...
in several files, 1 per page of the original with the name of the original
a1.pdf
a2.pdf
a3.pdf
b1.pdf
b2.pdf
b3.pdf
c1.pdf
c2.pdf
c3.pdf
and more ...
can help?

Related

Using cmd to move files with a specific filename mask

I am trying to use a simple windows cmd command to move a set of .csv files from one directory to another.
I know that this can be easily achieved through:
MOVE "*.csv" "D:/lorik_home"
The issue comes when I want to only move some specific files with a filename mask, for instance, I want to move all files which are in the .csv extension and start with the name: lorik_files_. I already tried using:
MOVE "lorik_files_*.csv" "D:/lorik_home"
This works when there is only one file of the format: lorik_files_20112233_09_33_33.csv, but when there are two files with the masks such as:
lorik_files_20112233_09_33_33.csv
lorik_files_20112233_10_23_42.csv
I get an error such as:
A duplicate file name exists, or the file cannot be found.
I need a hand for capturing those filename prefix masks, conditioned by .csv extension at the end.

How to create a batch file that will zip few different files in one .zip file

I want to create a batch/shell script for windows and mac that will take few different files with different types and will compress it to a .zip file.
I already saw a few questions and answers about it, but all of them either compress all the files in the folder or compress them individually.
Example (look at attached image):
I have a folder that contains 1.txt, 2.xml, a sub directory.
And I want to turn all of them into a .zip file.
If possible to get a solution both for windows and Mac.
On Windows there is the file 7zip.chm in directory %ProgramFiles%\7-Zip which is the help file of 7-Zip. Double click on this file to open the help.
On Contents tab there is the list item Command Line Version with the help pages:
Syntax ... Command Line Syntax
Commands ... Command Line Commands
Switches ... Command Line Switches
The target is to compress everything in folder test into a ZIP file with name of the folder as file name.
This could be done for example with the command line:
"%ProgramFiles%\7-Zip\7z.exe" a -bd -mx=9 -r -y -- test.zip "C:\Path to Directory\test\*"
This command line adds (a) everything in directory C:\Path to Directory\test recursive (-r) to a ZIP file with name test.zip in current working directory without progress indicator (-bd) using best ZIP compression (-mx=9) with assuming Yes on all queries (-y).
In other words the file test.zip in current directory contains after execution the subdirectory main with everything inside and the files 1.txt and 2.xml.

Cannot load files from a concatenated path

I am working on a script that will run daily. The script will compare individual configuration files from multiple host on one day with individual configuration files from a previous day. I am working on a CentOS host I have limited access to - meaning I can't make major changes.
Details
My hosts are running a cron job that uploads their configuration file to an sftp server in a generic stable directory (/var/log/Backups) by hostname (hostname.txt).
A cron job on the server creates a date stamped directory and moves the files from /var/log/Backups to /var/log/Backups/ddmmyyyy.
Later, well after all sftp and file move operations I want to load an array with the file names in a current directory and I load an array with matching file names from the previous days directory.
I want a script to diff the matching file names and output the information to a single text file.
I can't get the array to load the current days files and echo them to the terminal. I get a file operation error.
Script:
#!/bin/bash
# Set current date
now=`date +%d-%m-%Y`
echo $now
base=/var/log/GmonBackups/
loc=$base$now
echo $loc
# Load files from /var/log/GmonBackups/$now into an array
t_files=`ls loc`
echo $t_files
Something along these lines might help you get further:
today=$(date +%d%m%Y)
yesterday=$(date --date=yesterday +%d%m%Y)
base=/var/log/GmonBackups
today_dir=$base/$today
yesterday_dir=$base/$yesterday
today_files=( $today_dir/* )
yesterday_files=( $yesterday_dir/* )
A few points:
prefer $() to ``
don't use ls to get your list of files because it's not robust
I didn't put quotes around the variables because there are no spaces in your directory names.

Efficient batch processing with Stanford CoreNLP

Is it possible to speed up batch processing of documents with CoreNLP from command line so that models load only one time? I would like to trim any unnecessarily repeated steps from the process.
I have 320,000 text files and I am trying to process them with CoreNLP. The desired result is 320,000 finished XML file results.
To get from one text file to one XML file, I use the CoreNLP jar file from command line:
java -cp "*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props config.properties
-file %%~f -outputDirectory MyOutput -outputExtension .xml -replaceExtension`
This loads models and does a variety of machine learning magic. The problem I face is when I try to loop for every text in a directory, I create a process that by my estimation will complete in 44 days. I literally have had a command prompt looping on my desktop for the last 7 days and I'm nowhere near finished. The loop I run from batch script:
for %%f in (Data\*.txt) do (
java -cp "*" -Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP -props config.properties
-file %%~f -outputDirectory Output -outputExtension .xml -replaceExtension
)
I am using these annotators, specified in config.properties:
annotators = tokenize, ssplit, pos, lemma, ner, parse, dcoref, sentiment
I know nothing about Stanford CoreNLP, so I googled for it (you didn't included any link) and in this page I found this description (below "Parsing a file and saving the output as XML"):
If you want to process a list of files use the following command line:
java -cp
stanford-corenlp-VV.jar:stanford-corenlp-VV-models.jar:xom.jar:joda-time.jar:jollyday.jar:ejml-VV.jar
-Xmx2g edu.stanford.nlp.pipeline.StanfordCoreNLP [ -props YOUR CONFIGURATION FILE ] -filelist A FILE CONTAINING YOUR LIST OF FILES
where the -filelist parameter points to a file whose content lists all
files to be processed (one per line).
So I guess that you may process your files faster if you store a list of all your text files in a list file:
dir /B *.txt > list.lst
... and then pass that list in the -filelist list.lst parameter in a single execution of Stanford CoreNLP.

get the files name from text file and process them using windows batch script

I have a file which has the below content. this is diff list between two tags
type files.txt
A demo.bat
M tmp1.bat
M tmp2.bat
D test1.bat
here I need only A(addition) and m(modified) files. D(deleted) files should be ignored. How to grep only these files in windows batch. after that I need to get last column which is file names. now we will have only file names. these files are located in the same folder. Now we need to run the scripts one by one by using timestamp. I need to run only modified\created scripts by timestamp. Can someone tell me how to do this using windows batch script?
To get the file names in the file which has A or M in the first column.
$ awk '$1~/^(A|M)$/{print $2}' files.txt
demo.bat
tmp1.bat
tmp2.bat

Resources