我希望我的 MacBook 每次从睡眠模式恢复时运行一个脚本。
我的代码非常简单:
tell application "Finder"
if exists (disk "HDD") then
do shell script "diskutil eject HDD"
else
do shell script "diskutil mount HDD"
do shell script "diskutil eject HDD"
end if
end tell
Run Code Online (Sandbox Code Playgroud)
我在 CD-ROM 托架中安装了第二个 HDD,每次从睡眠模式恢复时,我都能听到驱动器旋转的声音,即使它的当前状态尚未安装。但在驱动器上强制执行安装/弹出命令可以解决此问题。唯一的缺点是我必须手动执行此操作;现在我想克服这个问题。
有人可以帮我解决这个问题吗?
我用mv -v命令移动了一堆文件.所以最后我有一个包含这样的文本文件:`
/Volumes/[TV Shows]/Movie 1.avi --> /Volumes/Downloads/Movie 1.avi
/Volumes/[TV Shows]/Movie 2.mp4 --> /Volumes/Downloads/Movie 2.mp4
Run Code Online (Sandbox Code Playgroud)
`
我需要Downloads根据此文本文件将每个文件从后面移动到其原始位置.原始位置将是-->我的文本文件内部之前的字符串.匹配标准是filename.
任何帮助将非常感激.
@jeremysprofile
我的文件可以在这里找到
在我的Mac上,我使用了以下代码:
#!/bin/bash
while IFS= read -r line; do
#use http://wiki.bash-hackers.org/syntax/pe#substring_removal to grab the parts we want
origin=${line% --> *}
current=${line#* --> }
mv -- "$current" "$origin"
done < ~/Desktop/myTextFile.txt
Run Code Online (Sandbox Code Playgroud)
结果的第一行是:
WYSIWYG:Desktop cip$ ./myMove.sh
mv: rename /Volumes/Public/English/[Sorted TV Shows]/Dimension/Dimension.404.s01e01.WEBDL.720p.NewStudio.TV.mkv -> /Volumes/Public/Downloads/from_tv_shows/Dimension.404.s01e01.WEBDL.720p.NewStudio.TV.mkv to /Volumes/Public/English/[Sorted TV Shows]/Dimension/Dimension.404.s01e01.WEBDL.720p.NewStudio.TV.mkv -> /Volumes/Public/Downloads/from_tv_shows/Dimension.404.s01e01.WEBDL.720p.NewStudio.TV.mkv: No such file or directory
mv: …Run Code Online (Sandbox Code Playgroud)