Sponsored Content
Top Forums Shell Programming and Scripting Create a list of files from alias by script Post 303015255 by Tapiocapioca on Saturday 31st of March 2018 10:23:22 AM
Old 03-31-2018
Quote:
Originally Posted by RudiC
Not sure I understand, but does this help:
Code:
FN="randomname.png"
for i in {1..10}; do P=$(( RANDOM * (${#FN} - 4) / 32768 )); T=${FN:P:1} ; echo ${FN:0:P}${T^}${FN:P+1}; done
raNdomname.png
randomName.png
randOmname.png
ranDomname.png
ranDomname.png
randomnamE.png
raNdomname.png
randOmname.png
rAndomname.png
randomName.png

?
Use this randomly generated name for the copy operation.

Mmmmm... No I think am not clear to explain, I try again making one example better

I recive one list of pictures like this, this is one TXT file

<01>CBS.png<02>
cbs.png
CBS HD.png
CBS SD.png
CBS HD +1.png

<01>E!.png<02>
<01>Disney Channel.png<02>
DISNEY CHANNEL.png
DISNEY CHANNEL HD.png
<01>Fox.png<02>
FOX.png
FoX.png
FOX HD.png
FOX FHD.png
FOX FHD.png
Fox +1 HD.png
Fox +2 HD.png
.
.
The list Is long like 2000 channels, the channels are inside the tags <01><02>

I recive also una usb key with the pictures I wrote with the blue color

So I have the foldre /pictures/ with inside the files

CBS.png
E!.png
Disney Channel.png
Fox.png
.
.
.
plus other 2000 files.

I need create the files I wrote in orange color, so in my mind I want make one file .sh to execute and duplicate the files blue to the files orange. I want make one file like this

cp /pictures/
CBS.png /pictures/alias/cbs.png
cp /pictures/CBS.png /pictures/alias/CBS HD.png
cp /pictures/CBS.png /pictures/alias/CBS SD.png
cp /pictures/CBS.png /pictures/alias/CBS HD +1.png
cp /pictures/Disney Channel.png /pictures/alias/DISNEY CHANNEL.png
cp /pictures/Disney Channel.png /pictures/alias/DISNEY CHANNEL HD.png
cp /pictures/Fox.png /pictures/alias/FOX.png
cp /pictures/Fox.png /pictures/alias/FoX.png
cp /pictures/Fox.png /pictures/alias/FOX HD.png
cp /pictures/Fox.png /pictures/alias/FOX FHD.png
cp /pictures/Fox.png /pictures/alias/FOX FHD.png
cp /pictures/Fox.png /pictures/alias/Fox +1 HD.png
cp /pictures/Fox.png /pictures/alias/Fox +2 HD.png

So when I execute it will gnerate all alias pictures I need inside the folder /pictures/alias/

I tried to do it with the command

Code:
awk -vlines=$(cat /pictures/alias_list.txt | wc -l) -vsource="/pictures/" -vtarget="/pictures/alias/" '/<02>/{getline;while($0 !~ /<01>/){print "cp " source SOURCE OFS target $0;if(NR==lines){exit};getline}} /<01>/{getline;SOURCE=$0;next}' /pictures/alias_list.txt > /pictures/alias.sh

But is not working, I hope is more clear now Smilie

Excuseme if my english is not really well!

Last edited by Tapiocapioca; 03-31-2018 at 12:01 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies

2. Shell Programming and Scripting

Shell Script Create List of Deleted Files

Hi, I want to put all the deleted files in a txt file. Because i want to backup my image server which has thousands of jpg images. I wrote a shell script which will copies images from image server to backup image server. I setup a cronjob which runs on every five minutes. & through timestamp it... (8 Replies)
Discussion started by: mirfan
8 Replies

3. Shell Programming and Scripting

How to create multiple list of files in a directory ?

Hi, i have say 100 files in a directory. file1.log file2.log file3.log file4.log file5.log file6.log ... ... ... file99.log file100.log ========= I need to create another file which contains the list of al these log files. each file should contain only 10 log file names. it shud... (4 Replies)
Discussion started by: robinbannis
4 Replies

4. Shell Programming and Scripting

Create files from a list and then populate them

I have a list of filenames that I want created - they must be created via a certain naming convention due to the software I'm using. Once they are created I have another file that will be used to populate them with data. So far this is what I have: #For each line in text file "foo_txt" create... (2 Replies)
Discussion started by: MaindotC
2 Replies

5. Shell Programming and Scripting

Create an alias

I want to create an alias cpage4 and create a postscript file For example I want to call cpage4 file.f which creates the file file.ps I have written like this but don't know how to continue alias cpage4 '/usr/bin/mpage -m40 -4AHP- \!* (6 Replies)
Discussion started by: kristinu
6 Replies

6. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

7. Shell Programming and Scripting

Create empty files from a list on file

Hello Guys. Please I would like to create empty files from a list In file1 will be the followin values, so i will like to create for each name a empty file. file1 2191off-r0.sps 2192off-r0.sps 2193off-r0.sps 2194off-r0.sps 2195off-r0.sps So I need to get 5 empty files. Thanks for... (7 Replies)
Discussion started by: jiam912
7 Replies

8. Shell Programming and Scripting

Create a list of missing files

Hello Guys I have a big list of files in one directory. And Some are missing . Example ls -l 2191off-r0.sps 2193off-r0.sps 2194off-r0.sps 2197off-r0.sps 2198off-r0.sps 2200off-r0.sps I would like to create a file with the list only missing files. Or if is possible to create in ... (4 Replies)
Discussion started by: jiam912
4 Replies

9. Shell Programming and Scripting

Script or alias to backup all files opened by vi

we want to backup all opened files by vi before editing also with version information. i wrote below alias to backup crontab file content with version info. What i want know is to make this opened files by vi. We want to prevent user mistakes by adding this alias. alias crontab='DATE=$(date... (4 Replies)
Discussion started by: sebu
4 Replies

10. Shell Programming and Scripting

Scan directories and create a list of files

Gents, Please can you help. I want to create a list which contends the complete patch of the location of some directories with the size of each file. need to select only .txt file In this case I am try to find the subdirectories tp1 and tp2 and create the output list. jd175-1 tp1... (3 Replies)
Discussion started by: jiam912
3 Replies
All times are GMT -4. The time now is 09:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy