Bulk extension changer - batch-file

I would like to make .bat file which will be changing all files on all discs with extension .xxx to extension .yyy. It's just an example because I will want to add more file extensions like: change all .aaa, .bbb, .ccc, etc. files to extension .ggg.

You can download this script from Microsoft's Script Center. It can change file extensions in bulk:
This batch script can be used to change file extensions in bulk. File extensions are renamed for all matching files in the current folder and in all subdirectories.It supports the following.1. Change extension for all the files in the current folder and all sub folders.
You can also use cmd or file renaming utilities.
You can do it using rename command, the general form is:
RENAME [drive:][path]filename1 filename2
Or
REN [drive:][path]filename1 filename2
For example;
REN *.xxx *.yyy
And also there are some file renaming utilities that you can use for the same:
Bulk Rename Utility,
Bulk Extension Changer
For more detail please refer to this link.

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

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.

Check if file exists in 2 directories, delete files that aren't in both directories

So, I'm programming a game, but the compiler I use is written as a Windows batch file. I'm using Windows 10 as my operating system.
In my game files, I have one folder with images, and another folder with upscaled versions of those images that have the same file name and extension.
What I want to do is have the batch file go through all the images in the directory with the upscaled images, and check if a file with the same name and extension exists in the directory with the original images. If it doesn't exist in the original directory, it will delete it from the upscaled directory.
I got it working using an answer over here:
Batch Extract path and filename from a variable
All I had to do was extract the file name and extension, and then run all the files in one folder through the loop, checking if the file exists in the other folder.
Here is my code:
for %%i in (%folder1%\*.png) DO (
if not exist "%folder2%\%%~nxi" ECHO %%~nxi
)
If you actually want to delete the files, change ECHO to del /q, be warned you will lose files, so make sure you have backups.

Batch file to take backup of the files

I am new to this , Actually my requirement is to take backup of some XML file from one machine to another machine .So my senario would be when i click on the batch file it will create a new folder on the second server (name of the folder should be date and time )and under this folder it paste all the copied files .
I need to create a new folder every time as i am doing version control.
Thanks
VG
The batch file is very simple
#echo off
setlocal
set "copydest=%date%_%time%"
for %%i in (/ - : .) do call set "copydest=%%copydest:%%~s=%%
xcopy "c:\path\to\your\datafiles\*.xml" "c:\parent\%copydest%\"
which should copy the .xml files from the directory c:\path\to\your\datafiles\ to a new directory under c:\parent\which has the date/time as its name.
The precise structure of that date/time depends on your settings. If you don't tell us what your settings are, we'd have to write a book about all of the possible combinations - not going to do that.
The for %%i... line does the removal of the common date/time separators; of these : and / are the important ones since they are invalid in a filename.

batch rename files with different file extensions to 1 extension

I'm recently new to batch scripting. I need to rename a few thousand files, each one having a different file extension to a single common extension. The files come off a machine like so:
1.2.840.113619.2.131.3171610912.1353091118.893703
which windows tells me is a type "893703" file because of the fullstop(.) position.
So I need to turn this example:
1.2.840.113619.2.131.3171610912.1353091118.893703
1.2.840.113619.2.131.3171610912.1353091118.907596
1.2.840.113619.2.131.3171610912.1353091118.920723
1.2.840.113619.2.131.3171610912.1353091118.932988
1.2.840.113619.2.131.3171610912.1353091118.945443
into this
1.2.840.113619.2.131.3171610912.1353091118.893703.IMA
1.2.840.113619.2.131.3171610912.1353091118.907596.IMA
1.2.840.113619.2.131.3171610912.1353091118.920723.IMA
1.2.840.113619.2.131.3171610912.1353091118.932988.IMA
1.2.840.113619.2.131.3171610912.1353091118.945443.IMA
I can edit the text string before the extension, and change a series of the same extension, but I'm not sure how to deal with files of different extensions.
I'm using Windows 7.
Run the following on the command line:
ren *.* *.*.IMA

Resources