Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team,

I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.

Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338

Subfolder will be always with timestamp Invoice<timestamp>
Eg:/Interface/data/test/IN/Invoice20180607233338
/Interface/data/test/IN/Invoice20180608113639
/Interface/data/test/IN/Invoice20180609118630

Subfolder will have csv files like
test1.csv
test2.csv
test3.csv

Requirement is to move all files from subfolder to parent IN folder and delete subfolder.

Subfolder will always begin with Invoice

OS is UNIX, Solaris.

Please advise on the shell script and let me know if any details required.

Thanks,
Varun

Welcome to the forum.

Any attempts / ideas / thoughts from your side?

I tried with below code, but it says bad find command

TIMESTAMP=`date +%d%m%Y.%H%M%S`


find /Interface/data/test/IN -type d -name Invoice* | grep -v ' '> /Interface/data/test/INVOICELIST


INVOICELIST=/Interface/data/test/INVOICELIST

for i in `cat ${INVOICELIST}`
do

  echo $i >> /Interface/data/test/INVOICELIST.$TIMESTAMP
  echo "------------------" >> /Interface/data/test/LIST.$TIMESTAMP
  cd $i
  mv * /Interface/data/test/IN >> /Interface/data/test/LIST.$TIMESTAMP


done


#find /Interface/data/test -type f -name INVOICELIST* -mtime +20 -exec rm {} \;

Try (untested)

cd /Interface/data/test/IN
for PN in Invoice*
  do	cd $PN
	mv * ..
	cd ..
	rmdir $PN

   done

Thanks for the response, I will execute it and let you know..

What does PN mean here ?

Thanks,
Varun

PN is a shell variable; short for path name.
Please make sure to test in a sandbox environment; You may want to add decent error checking, too!

When I run it, it says Invoice* doesn't exist.

Invoice is a subfolder of IN parent folder