Question

This is what I have so far - my dropbox public URL creation script for a directory of public URLs (getdropbox.com - gpl I think). My LIST file was created using ls in the following fashion:

ls -d ~/Dropbox/Public/PUBLICFILES/* > LIST

dropboxpuburl.sh:

for PATH in `cat LIST`
do
   echo $PATH
   dropbox puburl $PATH > ~/URLLIST/$PATH
done

Now this creates a whole series of files - each with the dropbox puburl in them.

The question is: How can I cause this script to redirect all the public links into one text file, each on a new line - perhaps with the name PUBLIC-DIRECTORY-LIST?

Was it helpful?

Solution

Is this what you are trying to achieve?

for PATH in `cat LIST`
   do
      echo $PATH
      dropbox puburl $PATH >> filename
   done

OTHER TIPS

OK, I've got it working using the suggestions given to me here:

for PATH in `cat LIST`
do
    echo $PATH
    dropbox puburl $PATH
done > PUBLIC-DIRECTORY-LIST

It creates a list of the directories, and below them the public link. Now it is time to prune the directories for a clean text file of links.

The => creates the files and adds something to the first line. >> appends to it on a new line.

echo txt=>PUBLIC-DIRECTORY-LIST.txt |
echo another text>>PUBLIC-DIRECTORY-LIST.txt 

You should use while read with input redirection instead of for with cat filename. Also, in order to avoid variable name conflicts I changed your path variable to lowercase since the shell uses the all-caps one already. It won't affect your interactive shell, but it could affect something in your script.

Also, assuming that you want the lines from your input file to be displayed to the screen as a progress indicator, but not captured in your output file, this echo sends it to stderr.

while read path
do
    echo $path >&2
    dropbox puburl $path
done < LIST > PUBLIC-DIRECTORY-LIST
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top