Need to trim the names of file names

filenameskshrename

enter image description hereI have files in UNIX directory which have a unique number starting with, i have to remove the unique id followed by '-' from the file name and need to have regular file.

Example: 32456113-report.pdf

Required File name in the database: report.pdf

I have file names of all kind of extensions .pdf, .doc, .xls, .txt but have the same number in the front.

I am using winscp to test or view the data and i am running a shell script by registering it as a host concurrent program in oracle apps.

Best Answer

Not entirely sure I understand what you are trying to do, but I believe a simple bash script as follows would work

for f in * ; do mv "$f" "$(echo "$f" | cut -d- -f2)"; done

If you don't like the echo to cut nonsense, I can look up the string rules in bash for you.

Related Question