Select multiple files with the same extension in .bat file - file

i found a script that converts a certain subtitle form , but to make it work i need to rename the subtitle file to "test.srt", then after coonverting , i rename it back to its original name , and its really annoying to keep repeating the process and to name each subtitle file on its own , i want the script to convert all the files in that folder that ends up with ".srt", not only to "test.srt" file
the bat file is like this :
"perl ps3_friendly_arabic_subs_converter.pl test.srt"
it uses the perl script to convert the file named "test.srt" , i tried to make it convert all the files that ends up with ".srt" , and i edited it this way
"perl ps3_friendly_arabic_subs_converter.pl *.srt"
and yeah it didn't work , so please anyone knows how ? thanks in adnvance

for %a in (*.srt) do perl ps3_friendly_arabic_subs_converter.pl "%a"
For each .srt file (in current folder), execute the indicated script passing the file as argument.
To execute it from a batch file, it is necessary to escape the percent signs, replacing each % with %%

Related

in batch copy the file name but not file extention

So i am converting excel files into a .txt files using vbs, and the input file name needs to be the same as the output file name with the changed file extension obviously. Whats making this so hard is the fact that I using this as basically a file converter so the names of the files will be random.
The way I load the input file is by is using the %1 command and just pass in the input file after I call the batch like this.NOTE: the .xlsx can be changed to any .xlsx file that i need to convert.
C:\tabdim>conversion_batch_file.bat **C:\tabdim\2160707.xlsx**
In the batch file (C:\tabdim\conversion_batch_file.bat) Note: the rest of the sql has been replaced with x's.
%windir%\SysWow64\wscript.exe C:\tabdim\combined.vbs **%1**
sqlcmd - xxxxxxxxxxxxxxxxxxxx
bcp xxxxxxxxxxxxxxxx "**C:\tabdim\20160707.txt**" xxxxxxxxxxxxxx
sqlcmd - xxxxxxxxxxxxxxxxxxxx
If there was any way to do something like this
"%1- last 4 characters+".txt""
I know that is totally wrong syntax, I'm just kind of using words to describe kind of what I'm trying to have happen.

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

How to write batch file which use the name of one file as part of the name of another file

I have some java executable program initialized from cmd. My problem is as following: I would like to read all files from some directory. Next, I would like to run the program as many times as many files I have in my folder. The required inputs are the path to the file with data and the name of the file where the results will be written. Now my question is, how can I write a simple batch file which will do it for me?
For example:
I have a list of files in my folder
file_1.xls
file_2.xls
file_3.xls
I want to run a loop and for each file initialize line specified below:
java -jar -Xmx1000M Program.jar pathToInputFile PathToOutputfile
For example for file file_1.xls I want to write the result to the file with the same name but different extension and at the begining of this file add some constant prefix. In case of file_1.xls the results I would like to write as Output_file_1.txt
for file_2.xls -> Output_file_2.txt
for file_3.xls -> Output_file_3.txt
and so on...
Can anyone help me?
pushd "c:\excel_files"
for %%F in (*.xls) do (
java -jar -Xmx1000M Program.jar "%%~nxF" "Output_%%~nF.txt"
)
Though I'll recommend you to use -classpath and direct call of the entry point class instead of direct call of the .jar .

Batch File Command throwing error in loop

Here is the situation. I need to "type" a .sj files content, then save it as an .js file. This is not the same as a rename, as the encoding is different. I am very new to Batch File syntax, but proficient with other programming languages. Here is what I have tried:
call for %%i in (.\*.js) do type %%i > %%i.js
But this is giving me the "%%i is unexpected at this time" Error.
If you need me to provide more insight, I will be happy to.
BACKGROUND: Trying to use JSDoc3 on .sj files but the encoding is not compatible. Using an encoder did not work either. What did work is copying and pasting the contents into a new file with encoding UTF8. But like I stated, a program like UTFCast did not work.
Two percent signs without anything in between (in a batch file) are treated like a single percent sign in a command (not a batch file).
Moreover CALL command enables a user to execute a batch file from within another batch file.
So from cmd you need to run only below..
for %i in (.\*.js) do type %i > %i.js
if you want to learn more...
for command
call command

Wildcards and the MOVE command in a batch file - Wildcard not recognised as such

I have a batch file with the following line in it:
move d:\cdr\C0*.%yyyy%-%mm%-%dd%*.csv d:\CDRArchive\%yyyy%%mm%\
where the variables yyyy mm and dd are for their resective parts of a given date. When I run this, the batch file parses the variables out correctly, but I doesn't recognise the wildcard character *, so I get the following line:
> move d:\cdr\archive\C0*.2013-09-08*.csv d:\CDRArchive\201309\
A duplicate file name exists, or the file
cannot be found.
Any help is much appreciated.
It works fine, once the target folder is created. Note that the error message you supplied shows that the filespec is wrong or the folder is wrong. The error message you get when they are right is shown below. (tested in Windows 8)
d:\>move d:\cdr\C0*.2000-10-01*.csv d:\CDRArchive\200010\
Cannot move multiple files to a single file.
d:\>md d:\CDRArchive\200010\
d:\>move d:\cdr\C0*.2000-10-01*.csv d:\CDRArchive\200010\
d:\cdr\C0abc.2000-10-01.aaa.csv
d:\cdr\C0abc.2000-10-01.bbb.csv
d:\cdr\C0abc.2000-10-01.ccc.csv
3 file(s) moved.

Resources