Trying to automate some work stuff and this includes many folder generations but and I was thinking of using a dynamic array to do this, let me know how this sounds.
First Part of my Script is to export a directory list using the:
ls /home/USER/Downloads/ > "/home/USER/Desktop/scripts/FolderList.txt"
and it gives the output as expected:
Folder With Some Long Title
Folder With Another Long Title
In this example I only gave (2) but there could be upwards of 1500+ folders and I have already written the commands to create the other folders on my server and name them automatically based off the original folder name, but the problem I have is I want my scripts to index thru all the folders and preform my commands (there are about 8 that are mostly string manipulations and such). So I was thinking of getting the count of the number of items in the Directory then write them to the text file mentioned above, then using a FOR-Loop to run that number of times that will contain my 8 or so commands? any thoughts or better ideas?
I Can get the count using:
wc -l FolderList.txt | awk '{ print $1 }'
But I'm not sure how to create or manage a Dynamic Array and use it with the for-loop to index thru my commands.
here is some of the script that goes with it currently some commented out for modular testing:
#TestString="Customer Info (YEAR) [PMNAME] [OWNERNAME] [EETYPE]"
cd "/home/USER/Downloads/"
ls /home/USER/Downloads/ > "/home/USER/Desktop/scripts/FolderList.txt"
wc -l FolderList.txt | awk '{ print $1 }'
#CUSTINFO=${TestString/(*)*}
#YEAR=$(grep -o '(.*)' <<<"$TestString")
#RESO3=$(grep -o '\[.*\]' <<<"$TestString")
#RESO2=${RESO3//\[PMNAME\]/}
#RESO_FINAL=${RESO2//\[EETYPE\]/}
#FULL_NAME=$TITLE_FINAL$CUSTINFO$YEAR
#mv "/home/USER/Downloads/$DOWNLOAD_NAME" "/home/USER/Downloads/$FULL_NAME"
#for f in */* ;do fp=$(dirname "$f"); ext="${f##*.}" ; mv "$f" "$fp"/"$fp"."$ext" ;done
Asked by user354662
(35 rep)
May 30, 2019, 03:25 AM
Last activity: May 30, 2019, 06:57 AM
Last activity: May 30, 2019, 06:57 AM