Is it possible to delete files with a text file as input.
1.choose the text file
2. choose a directory or volume
3. delete all the files (in textfile)
This would save me a lot of time!!
Thanks in advance - Peter
Is it possible to delete files with a text file as input.
1.choose the text file
2. choose a directory or volume
3. delete all the files (in textfile)
This would save me a lot of time!!
Thanks in advance - Peter
Hi retepp,
Maybe the following code gets you started. It will ask you to choose a folder and text file, then read file names from the text file (one per line) and finally combine each found file name with the chosen folder path to delete the corresponding file.
Text file sample contents:
test.pdf
Foldername:Subfoldername:filename.ext
So if you would choose the desktop as your folder path, the script would try to delete the following files:
/Users/yournamae/Desktop/test.pdf
/Users/yournamae/Desktop/Foldername/Subfoldername/filename.ext
set folderpath to (choose folder) as Unicode text
set chosenfile to (choose file) as Unicode text
try
set openfile to open for access chosenfile
set filecont to read openfile
close openfile
on error errmsg number errnum
try
close access openfile
end try
error errmsg number errnum
end try
set filenames to paragraphs of filecont
repeat with filename in filenames
if length of filename is greater than 0 then
set filepath to POSIX path of (folderpath & filename)
try
set command to "rm " & quoted form of filepath
do shell script command
end try
end if
end repeat
Thanks this works okay
One more thing though:
The files are scattered all over a particular Volume.
Is it posible to find those files and remove them after they where found, or even better, move them to a directory on that Volume called “Moved_Items”