LINUX.ORG.RU

История изменений

Исправление Desmond_Hume, (текущая версия) :

А теперь получилось и с переменными. Фух … без всяких анонимов справился, получается.

#!/bin/bash

initial_folder="/home/$USER/Documents/Test Files/"
test_folder="/home/$USER/Documents/Test Files/test/"
originalFiles_folder="/home/$USER/Documents/Test Files/original files/"

for a in "$initial_folder"*
	do
		function filetype_is {
							
			file "$a" |  cut -d ":" -f 2 | cut -d " " -f 2
		}		

		if [ $(filetype_is) = "directory" ]; then
			:
		elif [ $(filetype_is) = "Unicode" ]; then			
			mv "$a" "$test_folder"
		elif [ $(filetype_is) = "ISO-8859" ]; then
			iconv -f WINDOWS-1251 -t UTF-8 -o "${a%}.converted" "$a" && mv "${a%}.converted" "$test_folder" 
		else 
			:
		fi
	done

find "$initial_folder" -maxdepth 1 -type f  -exec mv {} "$originalFiles_folder" \;

Исправление Desmond_Hume, :

А теперь получилось и с переменными. Фух … без всяких анонимов справился, получается.

#!/bin/bash

initial_folder="/home/$USER/Documents/Test Files/"
test_folder="/home/$USER/Documents/Test Files/test/"
originalFiles_folder="/home/$USER/Documents/Test Files/original files/"

for a in "$initial_folder"/*
	do
		function filetype_is {
							
			file "$a" |  cut -d ":" -f 2 | cut -d " " -f 2
		}		

		if [ $(filetype_is) = "directory" ]; then
			:
		elif [ $(filetype_is) = "Unicode" ]; then			
			mv "$a" "$test_folder"
		elif [ $(filetype_is) = "ISO-8859" ]; then
			iconv -f WINDOWS-1251 -t UTF-8 -o "${a%}.converted" "$a" && mv "${a%}.converted" "$test_folder" 
		else 
			:
		fi
	done

find "$initial_folder" -maxdepth 1 -type f  -exec mv {} "$originalFiles_folder" \;

Исходная версия Desmond_Hume, :

А теперь получилось и с переменными. Фух … без всяких анонимов справился, получается.

#!/bin/bash

initial_folder="/home/user/Documents/Test Files/"
test_folder="/home/user/Documents/Test Files/test/"
originalFiles_folder="/home/user/Documents/Test Files/original files/"

for a in "$initial_folder"/*
	do
		function filetype_is {
							
			file "$a" |  cut -d ":" -f 2 | cut -d " " -f 2
		}		

		if [ $(filetype_is) = "directory" ]; then
			:
		elif [ $(filetype_is) = "Unicode" ]; then			
			mv "$a" "$test_folder"
		elif [ $(filetype_is) = "ISO-8859" ]; then
			iconv -f WINDOWS-1251 -t UTF-8 -o "${a%}.converted" "$a" && mv "${a%}.converted" "$test_folder" 
		else 
			:
		fi
	done

find "$initial_folder" -maxdepth 1 -type f  -exec mv {} "$originalFiles_folder" \;