I found this script in an older thread and it's not functioning how I need it to. I'm not a programmer and any help on this would be great. I need to copy files from one location to another based on a list. Here is the script I'm using:
When I run it, here are the results in terminal:
The problem is the files do not get copied to the destination folder. Help please. Thanks.
Code:
#!/bin/bash -x
target="/Users/mvineski/Desktop/Photoproject/Images"
destination="/Users/mvineski/Desktop/Photoproject/Chapter\ 1"
fnames=$(cat /Users/mvineski/Desktop/Photoproject/Chapter1.txt)
for i in $fnames; do
cp ${target}/${i} ${destination}/
exit 1
echo "copying $i"
done
echo "done"
Code:
Last login: Wed Apr 25 12:36:26 on console
mvineskis-Mac-Pro:~ mvineski$ #!/bin/bash -x
mvineskis-Mac-Pro:~ mvineski$
mvineskis-Mac-Pro:~ mvineski$ target="/Users/mvineski/Desktop/Photoproject/Images"
mvineskis-Mac-Pro:~ mvineski$ destination="/Users/mvineski/Desktop/Photoproject/Chapter\ 1"
mvineskis-Mac-Pro:~ mvineski$
mvineskis-Mac-Pro:~ mvineski$ fnames=$(cat /Users/mvineski/Desktop/Photoproject/Chapter1.txt)
mvineskis-Mac-Pro:~ mvineski$
mvineskis-Mac-Pro:~ mvineski$ for i in $fnames; do
> cp ${target}/${i} ${destination}/
> exit 1
> echo "copying $i"
> done
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
logout
[Process completed]
The problem is the files do not get copied to the destination folder. Help please. Thanks.
Last edited by a moderator: