thanks for reading & your suggestions. I’m moving files into respective directories, only some of the files use _ and some use - (underscore and hyphen) as delimiters. Is there a way to test for the different delimiters?
E.g.:
ParentDir
1897/
1898/
1994summer/
file-1897-001.txt
file-1897-002.txt
file-1898-001.txt
file-1898-002.txt
file_1994summer_001.txt
file_1994summer_002.txt
I’ve been processing with the following (verbose so I can understand it) shell script:
!/bin/sh
for f in *.jp2
do
base=${f%.txt}
echo "base fileName is $base"
fileName=`echo "$base" | cut -f 2 -d _`
echo "truncated fileName is $fileName"
dir=$fileName
echo "Directory is $dir"
mv -v "$f" "$dir"
sleep 1
done
When using the cut command, I’d like to be able to differentiate on the delimiter. Is that possible? Thanks in advance for your time & suggestions.
Cheers!
I’m almost sure bourne shell supported case processing. Don’t have access to one to test with.
The difference between bourne/bash/ksh/zsh would be in the shell wildcards patterns that each shell has as an extension to the basic patterns the bourne shell supported.
I hope this helps.