Software :: Making A Bash Script To Read In Different Files And Rename Output Files?
May 7, 2009
Until now i haven't had to dabble with bash scripts.
I have a program that reads in data files. These are named datafile01_R, datafile01_G, datafile01_B, they then increment, so datafile02_R etc i have about 600 of these. the program reads in 3 data sets at a time from each run, so files_01 r, g, and b.
The program then does its magic, and outputs about 40 different files, depending on the file, they gone to folders named R, G, B, psa, or tracking.
The program itself has configuration files to say where the files should gone when analyzed, there is also the config files that reads in the data sets.
At the moment i have to run one set of data, then go in and manually change the input file location, and run again. But, doing this, even though a different data set, the new set overwrites the old set in one of the output folders. So i need a way to increment the output filenames after they are written and before the program is run again with the new data set.
How would I rename all files with a leading decimal point recursivley? I some how got all my music files to have a decimal point.I tried the below and got a " sed argument to long".[CODE]find /media/MUSIC -type f -name "*.wma" | xargs -0 sed -i 's/.(.*)/1/'[CODE]
Another question, can i just use -type f with out -name ? I am sure that all the files got the decimal point added as the first character.
What bash command can I use to rename or change the extension or name of a batch of files (for example, from .php to .html)?
Furthermore, is there a simple bash or python script/command that can be used to open a batch of plain text files one-by-one, search for all instances of a specific word, and replace all of those instances with another word?
I'm trying to write a script to process some images and rename them, or more specifically, renumber them so that pg_0001.png becomes pg_0.png, pg_0002.png becomes pg_1.png, etc. I've looked at the rename command and sed, but I'm not really very familiar with these. It should also be part of a bash script that I've written for the processing of these files - this is what I have so far:
I named a number of files with spaces in them, and I want to replace the space with "_". However, every time I write a command in the shell with the file name (eg "Spring 2011"), the shell doesn't recognize the file or directory. What can I do about this? Is there any way to use the unicode character for a space?
I'm pretty new to bash scripting, but I really want to wrap my head around it.What I'm trying to do is: From directory "A": Go in to all subdirectories and rename all files within icrementally according to the directory name. SO:
I have scowered the internet for the answer to this one. I need a script to rename multiple files to the same exact name, run a program on the file then do the same for the next file. We have a unix backend system that is expecting to load the file with the filename of cards.in So I will have files named card.2009xxx, like i said i will have around 4 or five of those. I want the script to rename card.2009xxx to cards.in, run our unix program on cards.in which inturn changes the file name and once complete i want the script to rename the next cards.2009 to "cards.in"Until there are no more left in the directory and the unix program has processed all the files. All of this is occurring in the same directory. I have written some scripts but they fail by moving for example cards.200901 to cards.in then immediately moving cards.200902 to cards.in and that is not good because it is overwriting valuable data
I'm writing a bash shell script that among various other things will traverse through a directory with hundreds of files and rename those who match a pattern found in a config file. It's expected that only about one in ten files will actually match, and those who don't, will simply just be ignored for this purpose.
This should for instance cause the file "dBase program file December 1987.prg" to be renamed "Clipper source code December 1987.prg", and conversely "C++ source August 1996.cpp" to be renamed "C source code August 1996.cpp" etc.A sample file such as "Random Data File.dat" should not be renamed here since it's not mentioned in the config file..What is the quickest, most elegant way to do this in bash?I am thinking of using bash's built-in regex matching combined with the /bin/rename utility, but don't quite know how to get started to catch this..I guess there are plenty ways of doing this in perl and elsewhere as well, but since this has to integrate into a pre-existing bash script, that's what I'm looking for.Anyone out there with a spare moment to offer a hint in the right direction?
Quick question. I need to ensure that all my files within specific folders are marked as being read only if the folders name is 'Forms' for example. There may be many 'forms' folders on the server within many different directories.It is a requirement that everything within these folders are marked as being read only but people are not doing so for whatever reason, and would therefore like for it to be done automatically i.e. a script executed by a cron job every eve to esnure that all files within the forms directories are marked read only.
I am trying to write a bash script that will extract a .cbr (.rar) file, traverse the extracted files in alphabetical order and rename them 001.JPG, 002.JPG, 003.JPG, etc.So far I only have this much to extract it:
file1: have DNA sequences and each sequence will begin with > symbolfile2: have protein sequence and each sequence will start with > symbolfile3: BLAST result of file2 and each result will start with query= .my problem is i have to make a report file by combining these three in such way that first sequence from file1,first sequence from 2nd file and first result from file3 should be printed in a report file
I have wrote a 1 line command that parses a file, locates the IP Address in the file and then trims the output the way I want it, and then sorts numerically and by uniqueness and then >> appends to output.txt
I can get all the IP's into 1 file "output.txt", but what I am really looking for is some type of way to create a text file, for each IP it finds labeled xxx.xxx.xxx.xxx.txt and also put that ip address into that file..
I have bought an external usb hard drive on which I back up my three computers every once in a while.Space will quickly be used up.I can't find that little bit of research that I need yesterday.Here is what I would like to find:An application that eliminates doubles in identical files and renames files that have changed by appending the last saved date yyyymmdd to the file name.Does such an application already exist?
I have a script almost working except for 1 thing. What I'm trying to do is read a file that has the files that need to be FTP'd using a bash script. I have everything working except the reading of the file. It works outside of the ftp script I've wrote but once I put it in the FTP script it doesn't.
Here's the Script:
#Here's where the problem is that I know of
I've been playing w/ the exclamation points to see if that could be the problem, but so far no luck.
AKA "zipping on the fly .. the slow-as-molasses way." The list includes full pathnames to each file, and they're all in subfolders of the same parent folder (which, unfortunately, is not the root folder of the drive or system on which the files reside). A cleaned-up and radio-ready portion of the list looks like
What I'd like to be able to do is zip all the files in the list into a single archive, to avoid the step of having to copy them to the same location (presumably another folder on the HD) and then zip that folder. I'm more inclined to make provisions about extracting to a single folder at some other time. Is this possible in BASH, or would I have to consider a faster, more robust scripting language such as python or perl?
PI'm trying to write a script to list all open ports in the MINIUNPND chain in iptables and use the procotol, port and destination ip to open ports on another router using upnpc.Here is the output of iptables -L MINIUPNPD
I am working on a script that allows me to convert an IP address to a country name. I have 2 files. One that has text like: PORT.80 TCP SRC=x.x.x.x and the other is x.x.x.x United States. How can I combine these files so that the file output is PORT.80 TCP SRC=x.x.x.x United States?
Im trying to auto rename badly named mp3's using info from the id3 tag. I got a nice little program called id3ren, it works fine apart from it doesn't add the track number. Cant figure how to enable this function. The track numbers are in the ID3, but it just renames to Artist/Trackname. Any other users on here?
I just downloaded a copy of the Old Testament onto my laptop from the Windows side of my desktop.Alas, all of the links are in lower case and all of the file names came across in upper.way to rename all of the files in a directory to be in lower case instead of upper?
I guess the title says it all. I'm looking for a program that will rename a massive amount of files at once. JPGs specifically, or PNGs. More specifically,I'm creating a stopmotion movie. Using the program StopMotion. And for that, all you pictures, or frames, have to be named 001.jpg 002.jpg and so on. I've got about 300 or so images, and they're all named the default thing that my camera names them, you know, like DSCIM8520 or whatever. I'm looking for maybe a command line program or GUI is fine too, that will do this for me.
I have many files in a directory. They all have names with a .pdf extension. How can I remane all of them so that they are named as so... 1.pdf, 2.pdf, 3.pdf? I want to do it with one command or somehow that I do not have to manually rename each one.