in batch copy the file name but not file extention - file

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.

Related

Batch export in SAS for spk file

I need to export/import my spk file via windows Batch script.
For which I have been referring this document
But this document does not mention how to save the file (I mean with which extension .bat or .sas)
My command:
ExportPackage -profile "SAS_MW_TEST" -package "F:\mypath\Package4.spk" -objects "/_Applications/_05_MW/_01_SAS_MW/_20_Processes/savedesk(Folder)" -subprop -types "Condition,BusinessRuleFlow,ExternalFile,Cube,SearchFolder,Table,GeneratedTransform,OLAPSchema,InformationMap.OLAP,Measure,Column,Job.CubeBuild,Action,Library,MiningResults,DeployedJob,CalculatedMeasure,Hierarchy,InformationMap.Relational,RootFolder,Prompt,Document,ConditionActionSet,DecisionLogic,Dimension,Note,StoredProcess,PromptGroup,Job,OrchestrationJob,MessageQueue,Service.SoapGenerated,Level,SharedDimension,DeployedFlow"
ExportPackage is an executable program that you can run out of a batch file.
Use Notepad or any other text editor (which includes any SAS code editor), place the ExportPackage program command in the editor and use the File/Save As feature to save the file as something like myPackageExporter.bat
If the items in the package are say stored processes whose metadata says the source code is in an file system folder (aka source code repository), you will probably also want to zip up the folder.
This macro can help you prepare the batch script, ready for export: https://core.sasjs.io/mm__spkexport_8sas.html

SQLLDR command Error .Dat file not found

I am trying to load few values in Oracle table using SQLLDR command via Command Prompt. I am trying to set a variable to get users put file name which will be accepted in SQLLDR command. I have a Control file (.CTL), a Data file (.txt) however it is throwing error:
SQL*Loader-500: Unable to open file (sqlldrtest.dat)
even though I have mentioned a .txt file as Data file.
This is first time I am using SQLLDR with a variable. I have successfully used SQLLDR command earlier without any variable.
Please can anyone help me in rectifying this error.
My code for .BAT file is:
set /p reportname="Enter Your Report Name: "
SQLLDR USERID=login/password#database CONTROL=%reportname%.CTL, DATA=%reportname%.txt
pause
Remove the comma after the CONTROL= and make sure to change your password!
If it still doesn't work, please update your post to show the contents of your control file.
The problem is with the format of your DATA file. Your data file need to have .dat extension.
Change the extension of your DATA file from .txt to .dat
Your command should look like this -
SQLLDR USERID=login/password#database CONTROL=%reportname%.CTL, DATA=%reportname%.dat

Batch wildcards not accepted

How do I do reshacker -extract on all files in the system32 folder as well as get their filename and add .rc to the end of each output file.
reshacker.exe does not accept wildcards so im not sure what to do.
I have tried the following:
ResHacker.exe -extract C:\windows\system32\*.*, C:\resources\%1.rc, dialog,,
it is supposed to extract dialog data from each file in system 32 and save this data as %the_filename%.rc.

Select multiple files with the same extension in .bat 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 %%

Including .prn file with lpr command in Windows batch file

I need to do a downloadable Windows batch file (.bat) which runs lpr command on clients machine. That's easy. The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser.
Is there any way to include .prn file (Print-to-file -file) in batch file? Or can I somehow include the printer data on lpr command?
Thanks!
As far as know you cannot include print data in your lpr command. You can specify the file to print and that is it. But do you know the printer name of all the clients? It sounds like there might be a better way of deploying if the clients are on the same network.
You cannot include a .prn file in a .bat (or .cmd) file in any reasonable way (even if the .prn file is a text file). Again if clients are on the same network the .bat file (or .cmd) could access the .prn file stored in a shared place.
Lpr: Sends a file to a computer
running Line Printer Daemon in
preparation for printing.
Syntax
lpr [-S ServerID] -P PrinterName [-C
BannerContent] [-J JobName] [{-o | -o
l}] [-d] [-x] FileName
"The hard part is that the batch file must include the data to be printed also. Everything needs to be in one downloadable-file that could be ran by the enduser."
I'm a little unclear on this, however to me it sounds like you want the batch script to include the text of the data you wish to print?
It looks as if you can have the information in say a .txt file and pass it through lpr:
lpr -P printername -x file.txt
If you need information from a .prn file inside of this printed .txt file, you can try:
TYPE file.prn>>file.txt
However not sure if TYPE will work on a .prn file.

Resources