Regarding changing the file extensions of all files in a folder in ubuntu 14.04 - file

I have a folder containing number of files with extensions in .xvg format and i need to change them into .dat format. How can i do that..?
What are the commands that i need to give such that all those files extensions that are in .xvg format are converted into .dat format [without the file name getting changed,(example., abc.xvg should be converted into abc.dat),only file extension should be changed].

Try this
rename 's/.xvg$/.dat/' *.xvg
For a test run you can use this command:
rename 's/.xvg$/.dat/' *.xvg -vn
-v means "verbose" and it will output the names of the files when it renames them.
-n will do a test run where it won't rename any files, But will show you a list of files that would be renamed.

Related

Make a exclusion list + files list using winrar command line

I made this script below to make a backup of some files. It works fine, but i wanted make a list for the files that need be skipped from compressing.
For example:
my list.txt has all the files that will be compressed. But i wanted to make another list for the files that need be skipped, like exclusion_list.txt. Actually i put all files that i want be ignored from compressing into the command line, as shown below -x*\Test1 -x*\Test2.
But i really wanted to make a exclusion list for not keep changing the command line everytime i need to exclude a file or folder.
How i can do it?
"%winrar%\winrar.exe" a -x*\Test1 -x*\Test2 -ibck -ep1 -ilog%userprofile%\Desktop\log.log "compressed %date:/=.%.rar" "#list.txt"
From the documentation: the exclusion option -x also supports a list file when it is preceded by #:
"%winrar%\winrar.exe" a -x#exclusion_list.txt -ibck -ep1 -ilog%userprofile%\Desktop\log.log "compressed %date:/=.%.rar" "#list.txt"
with the file exclusion_list.txt containing:
*\Test1
*\Test2
By the way, there is even a console version of WinRAR, called rar.exe, which is a non-GUI version.

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.

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

IBM i PASE tar - Excluding files or directories

I want to exclude some directories from an archive using the PASE tar command on an IBMi but the [-X Exclude File] option doesn't seems to work for me.
I tried using an exclude file that just contained a file name (/home/JSMITH/data/sub2/file2.txt) and then one that just contained a pattern (*.txt), and neither archive operation omitted anything.
Given the following directory structure:
/home/JSMITH/data
/home/JSMITH/data/sub1
/home/JSMITH/data/sub1/file1.txt
/home/JSMITH/data/sub2
/home/JSMITH/data/sub2/file2.txt
/home/JSMITH/data/sub3
/home/JSMITH/data/sub3/file3.txt
and the following command:
/qopensys/usr/bin/tar -cvf /home/JSMITH/test.tar -X /home/JSMITH/excludes.txt /home/JSMITH/data
The entire /home/JSMITH/data structure gets included in the resulting archive.
I have tried using the /home/JSMITH/excludes.txt file with either of these contents:
/home/JSMITH/data/sub2/file2.txt
or
*.txt
How does one exclude files/directories/patterns from the IBMi PASE tar command?
You need the full path in the exclude file.
I created mine via ls /home/JSMITH/data/*.txt > /home/JSMITH/excludes.txt
If you're doing it by hand, make certain you haven't got any trailing whitespace.
Also, I used Notepad++ when I created mine by hand. I found that the green screen edtf created an EBCDIC file with CRLF in it, and that didn't exclude for me.
IBM i 7.1

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