我正在尝试搜索包含多个图像的文件夹,并将文件名中具有_master的图像移动到其他文件夹。以下是我所取得的成就,但我不断遇到错误
无法获取文件夹
tell application "Finder"
set the_files to get every file of folder "Mac HD:Users:anthonypassler:Desktop:skincare:"
end tell
tell application "Finder"
repeat with this_file in the_files
if name of this_file ends with "master.png" then
move file this_file to folder "Mac HD:Users:anthonypassler:Desktop:skincare:Test"
end if
end repeat
end tell
end
答案 0 :(得分:0)
无法获取文件夹
表示该路径无效,可能是拼写错误。
由于当前用户的桌面文件夹是Finder的 root 文件夹,因此格式较短:
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('disable-extensions')
chrome_options.add_argument('--screen-size=1280X600')
chrome_options.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36")
prefs = {"profile.managed_default_content_settings.images": 2}
chrome_options.add_experimental_option("prefs", prefs)
self.driver = seleniumrequests.Chrome(
executable_path='D:/chromedriver/chromedriver.exe', chrome_options=chrome_options)
self.driver.set_page_load_timeout(8)
self.driver.implicitly_wait(10)
try:
self.timelogger.info("sending request...")
response = self.driver.request(method='POST', url=buyurl, data=data, headers=headers, find_window_handle_timeout=8, page_load_timeout=8)
self.timelogger.info("...done")
except Exception, e:
self.timelogger.info("Exception: " + str(e))
continue
但是还有第二个错误:您必须删除 move 行中的tell application "Finder"
set the_files to files of folder "skincare"
repeat with this_file in the_files
if name of this_file ends with "master.png" then
move this_file to folder "Test" of folder "skincare"
end if
end repeat
end tell
关键字,因为file
已经是文件说明符。