I'm completely new to Shell scripting and I need to make a script that renames files with names like this: "aaa-b_ccc" where aaa b and ccc can change but b is a single character into files with names like this one:
"ccc'_bbb'_aaa" where ccc', bbb', aaa' are values I set accordingly to the original values aaa,b,and ccc, but not the same values. It's not possible to "calculate" the new values so I'm planning to make some kind of a csv file where I list old value -> new value. I already figured out that I can use SED to make easier changes but I'm just not smart enough to solve my problem :P
Sorry, but your description sounds ambiguous.
Please post an example of input filenames and output filenames, thanks. Use code tags when doing so, thanks.
Code tags are just as useful for logs, data and other snippets, as they separate that data from describing text and enhance readability as well as they preserve special characters and if somebody has something like a colon and a closing bracket, you would get a smiley but inside tags they will not substituted. They also preserve indention etc.
Your example is very small and readable, but generally it would be nice if you use them as most other users do, in case you have more extensive data or logs, code etc. next time.
Außerdem: Das Auge ißt mit
To your problem:
How are the new strings supplied? Do you have a list or something?
How is the relation between the entries in that list to the file names? Is there a translated definition of the countries already in that list?
Alright, will use code tags for longer examples and try not to use slang I didn't even notice that I wrote 'wud', too used to doing so.
The list is not created yet and will preferably be created in an excel sheet -> can be saved as csv file then. In this list I would also specify the translation of every country and replace the country names within the script similiar to the way I replace the other parts of the filename.
Ok, so assuming, as the substitution and keys etc. is still not clear, I suggest the following:
Have two lists; the one that is to be created (your csv file as you said) containing the stuff that will replace the placeholders or be added to the original file names and the other one be generated by listing the files that have to be renamed. The second list could be generated by a simple ls *.jpg or something more appropriate.
There will be some key or anything needed to bring the contents of both lists into relationship. Else the substitution would just be random or in an unwanted order, and that would be the last you want to have
When having the list you could do something like:
Here is the script:
This will not work 1:1 in your case as many things are still not clear yet but I hope you get the clue what I did. It should be possible to be adopted to your case.
You can play around with it with (placing variables at different positions etc.) some example data so you don't destroy things^^
Hey guys,
ive been working on this for about 2hrs now - without any solution.
At first I need to say I dont have skills in linux bash scripting, but I tried to use some codesnippets and manuals from google.
What I want to do:
I have different folders including 2 different filestypes with... (15 Replies)
Hi all,
i am new to this forum, unix and shell scripting.
I would really appreciate if you all can help me here..
I have files coming in the below format
'filename20513'13May06:03:45
filename are characters..
like 'ABDDUT20513'13May06:03:45
i need it to be renamed as... (17 Replies)
Hi,
In sftp script to get files, I have to rename all the files which I am picking. Rename command does not work here. Is there any way to do this?
I am using #!/bin/ksh
For eg: sftp user@host <<EOF
cd /path
get *.txt
rename *.txt *.txt.done
... (7 Replies)
I have some 50+ files in the following format :
abcd_vish_running_ZEBRA_20140818.dat_08-14-2014_23:08:23
abcd_vish_running_ZEB-RA_20140818.dat_08-14-2014_23:08:35
abcd_vish_running_ZEB_RA_20140818.dat_08-14-2014_23:08:37
abcd_vish_running_RI-NG_20140818.dat_08-14-2014_23:08:42... (5 Replies)
Hi all,
I'm working in a specific directory and I have file names which I'd like to rename but in a way in which I can specify the new filenames as @ARGV or user input at prompt.
Can someone shed some light on this?
Cheers :) (7 Replies)
Hi All
I have a folder that contains hundreds of file with a names
3.msa
4.msa
21.msa
6.msa
345.msa
456.msa
98.msa
...
...
...
I need rename each of this file by adding "core_" in the begiining of each file such as
core_3.msa
core_4.msa
core_21.msa (4 Replies)
Hey guys,
I'm really new to UNIX and shell scripting in general. For my internship I need to rename a bunch of files. Specifically, I need to change the first letter of each of the files to lowercase and I have to change the endings so they all basically look like "file_cone.jpg". I know I... (4 Replies)
Hi.
I need help with a little script that will be used to move some files to their parent directory, delete the directory, rename one file in the parent directory and delete another, then continue to the next.
Here's an example:
/var/media/Music/Genesis/1970 album - Trespass (2008 Box -... (4 Replies)
Hi Gurus,
I have some files(all ending with .out as extension).
Ex:
aa1.out
aa2.out
aa3.out
I would like to append each file with the current date to the end of the file so that they should become aa1_20090504.out.
So I am using rename as follows:
for i in path/aa* ; do mv $i... (5 Replies)
Hi,
I have a problem.
I have some text files in a folder. The names can be like:
emp.txt
emp1.txt
emp3.txt
32emp4.txt
What i need is i have to copy all the files which have "emp" string in their filename
to a different folder and those file names... (7 Replies)