I have a list similar to the one below in the lista.txt file:
mickey donald daffy bugs
I have a folder containing many files: filename1, filename2, ... filenameN.
I want to iterate through these files:
filename1 => mickey filename2 => donald ...
Can you provide me with a working sample code for this task?
This is not my style for your work. I would prefer you to publish what you have already tried, so I can help you debug it, but this problem is so simple that I will still bite.
x=1; for y in $(cat lista.txt); do mv $y filename$x; let x=$x+1; done
Using bash arrays:
files=( * ) i=0 while read -r new_name; do mv "${files[$i]}" "$new_name" (( i++ )) done < lista.txt
let "count=1" for newname in $(cat lista.txt); do mv "filename$count" "$newname" let "count++" done
, flac "filelist.txt" :
while read -u 9 filename ; do read -u 8 newname echo mv "$filename" "$newname" done 9<<<"$(ls -1 *flac)" 8< filelist.txt
.flac 9 " ", .list 8 " ".
, ( "-u 9" "9" ), , stdin ; , .
" " .
Linux krename, javascript. .
javascript , :
var files = [ "Mickey", "Donald", "Duffy" ]; function rename(){ // krename_index is one of many special variables which can be added via ui return files[krename_index]; }
, , , .
, :
[js; rename()]
$ . "", .
$