I have created a text file with a list of file names like below
022694-39.tar 022694-39.tar.2017-05-30_13:56:33.OLD 022694-39.tar.2017-07-04_09:22:04.OLD 022739-06.tar 022867-28.tar 022867-28.tar.2018-07-18_11:59:19.OLD 022932-33.tar I am trying to read the file line by line then strip anything after .tar with awk and use this to create a folder unless it exists.
Then the plan is to copy the original file to the new folder with the original full name stored in $LINE.
$QNAP= "Path to storage" $LOG_DIR/$NOVA_TAR_LIST= "Path to text file containing file names" while read -r LINE; do CURNT_JOB_STRIPED="$LINE | `awk -F ".tar" '{print $1}'`" if [ ! -d "$QNAP/$CURNT_JOB_STRIPED" ] then echo "Folder $QNAP/$CURNT_JOB_STRIPED doesn't exist." #mkdir "$QNAP/$CURNT_JOB_STRIPED" fi done <"$LOG_DIR/$NOVA_TAR_LIST" Unfortunately this seems to be trying to join all the file names together when trying to create the directories rather than doing them one by one and I get a File name too long
output:
......951267-21\n951267-21\n961075-07\n961148-13\n961520-20\n971333-21\n981325-22\n981325-22\n981743-40\n999111-99\n999999-04g\n999999-44': File name too long Apologies if this is trivial, bit of a rookie...