AppleScript: match and delete files in folder
来源:互联网 发布:京东众包软件打不开 编辑:程序博客网 时间:2024/06/06 12:40
AppleScript: match and delete files in folder
Ask Question
up vote0down votefavorite
My photo camera allows to save pictures in RAW and JPG in parallel. I find this convenient because on my Mac I can quickly browse the JPGs and delete the "bad" ones. Besides, I keep the RAW files of the "good" JPGs in case I need to do some deep editing.
I would like to write an AppleScript which deletes all the "bad" RAWs (RAW files which don't have a corresponding JPG anymore). All files are in the same directory.
This is my outline (far away from correct syntax!):
tell application "Finder" set source_folder to choose folder with prompt "Please select directory." my clearFiles(source_folder)end tellon clearFiles(source_folder) set theItems to "" tell application "System Events" set theItems to get the name of every disk item of source_folder end tell repeat with theFile in theItems if the extension of theFile is "raw" and exists name of theFile & ".jpg" then tell finder delete (name of theFile & ".raw") in source_folder and tell end if end tellend clearFiles
osx applescript pattern-matching finder
add a comment
1 Answer
activeoldestvotes
up vote1down vote
try this
set source_folder to choose folder with prompt "Please select directory."tell application "Finder" set rawFiles to every file of source_folder whose name extension is "raw" repeat with aFile in rawFiles set baseName to text 1 thru -5 of (get name of aFile) set jpgFile to baseName & ".jpg" if not (exists file jpgFile of source_folder) then delete aFile end repeatend tell
0 0
- AppleScript: match and delete files in folder
- delete specific lines in a set of files in a folder
- Linux delete define files in correct dir and sub-dir
- Get program files folder in C#
- Read all files in a folder
- Cannot delete file or folder in windows
- 122.View the Exhibit and note the files available in the $ORACLE_HOME/dbs folder. The ASM instance i
- Use matlab to traverse the files in a folder
- Why are .goutputstream-xxxxx files created in home folder?
- Delete files or directories in bash shell
- Create folder and subfolder in Sharepoint
- how to delete "permission from trustedinstaller" folder in Win7/Vista
- VB & Excel Macro delete file and file folder
- 【软件自动化测试-QTP实战技能 20】== QTP_ Delete files from Temp Folder:删除Folder
- one command to delete all files with name "filename" in current dir and all its sub-dirs
- acl_users and user folder and user management in ZOpe
- delete files
- sharepoint2010 delete pic folder
- C. Andryusha and Colored Balloons
- 装配Bean
- Android -- RecyclerView实现顶部吸附效果
- 斐波那契堆(Fibonacci Heap)
- Swift Web 开发之 Vapor
- AppleScript: match and delete files in folder
- CodeForces782B The Meeting Place Cannot Be Changed 三分查找
- python 发送163邮件554 DT:SPM
- height:auto和height:100%的区别
- 阿里云部署的时候常用的Linux步骤
- Swift Web 开发之 Vapor
- 算法5:求两个已排序数组的交集和并集
- AndroidStudio 编译时遇到:Error:(246, 0) Gradle DSL method not found: 'testCompile()' (或者其他)问题
- VMware虚拟机已设置NAT仍无法连接网络