Skip to main content
Adding assumption
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

YouAssuming we know that all files have the filename suffixes .html or .txt and that all directories have the suffix .directory, you can use:

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

You can use:

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

Assuming we know that all files have the filename suffixes .html or .txt and that all directories have the suffix .directory, you can use:

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

added 16 characters in body
Source Link
Prvt_Yadav
  • 6k
  • 7
  • 39
  • 52

You can use:

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

You can use:

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

deleted 14 characters in body
Source Link
Prvt_Yadav
  • 6k
  • 7
  • 39
  • 52

untested

for i in *.txt *.html
 do
  mv "$i" "${i%i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

untested

for i in *.txt *.html
 do
  mv "$i" "${i%.*}.directory/$i"
 done 

Run this in same directory where you are having files.

for i in *.txt *.html
 do
  mv "$i" "${i%%.*}.directory/$i"
 done 

Run this in same directory where you are having files. It will remove trailing .txt and .html from file names and then will move files to destination directory.

Source Link
Prvt_Yadav
  • 6k
  • 7
  • 39
  • 52
Loading