有没有解决方案
来自不同外部硬盘驱动器的所有文件和文件夹的统一列表/目录,可用于移动和重命名项目,但稍后当连接该外部驱动器时,相关文件/文件夹会根据所做的更改进行重命名、复制、移动和删除在那个目录中。
这是因为连接所有外部硬盘非常困难和麻烦,即使连接所有硬盘也必须在组织所有驱动器中的每个文件的整个过程中运行。
基本上类似于 Adobe Lightroom 目录,但用于文件和文件夹。我们可以处理目录,并在连接 HDD 时将更改应用于原件。
有没有解决方案
来自不同外部硬盘驱动器的所有文件和文件夹的统一列表/目录,可用于移动和重命名项目,但稍后当连接该外部驱动器时,相关文件/文件夹会根据所做的更改进行重命名、复制、移动和删除在那个目录中。
这是因为连接所有外部硬盘非常困难和麻烦,即使连接所有硬盘也必须在组织所有驱动器中的每个文件的整个过程中运行。
基本上类似于 Adobe Lightroom 目录,但用于文件和文件夹。我们可以处理目录,并在连接 HDD 时将更改应用于原件。
没关系stackoverflow,经过三天的严格搜索,我找到了解决方案来完成我需要做的事情。
通过这个过程,任何人都可以在一个小的准备访问包(几乎是 MB)中仅拥有所有硬盘驱动器、服务器、NAS、云等中所有 TB 文件的链接,并且可以对其进行组织、标记、重命名和清理.
然后,一旦完成,就可以将所有链接替换为各自组织和修改位置中的原始文件,而无需任何麻烦和硬盘驱动器运行时间或压力。
我使用苹果脚本来告诉 finder 执行以下操作,但由于我缺乏编程基础和文件系统的工作原理,我经过了几次曲折、反复试验和反复试验。
解决方案:
苹果脚本三步到
仅使用文件夹和子文件夹(全部)在源文件夹和目标文件夹之间复制目录结构。但是使用文件的符号链接而不是文件本身。
将所有符号链接转换为 Mac finder 类型别名,以便可以使用 Apple 脚本处理它们。
用它们指向的原始文件替换所有别名。
每个步骤的脚本也与屏幕截图一起发布了详细的评论
步骤1:
set sourceFolder to choose folder with prompt "Choose Source Folder"
(* To prompt a window with to choose source folder *)
set destinationFolder to choose folder with prompt "Choose Destination Folder"
(* To prompt a window with the title choose destination folder *)
tell application "Finder"
do shell script "/opt/X11/bin/lndir " & quoted form of POSIX path of sourceFolder & " " & quoted form of POSIX path of destinationFolder & ""
(* Using shell to execute "lndir" command with its path (as there was a 'command not found' error initially)
and since we need to use HFS style paths of source and destination directories in the lndir command,
we are using the quoted form of HFS path i.e. POSIX style (because apple script's POSIX style paths of sourceFolder
and destinationFolder references used in the beginning lines of script are not used in shell *)
end tell
(* Installing lndir command to terminal is step 1 and it is downloaded using go from github (https://github.com/launchdarkly/go-lndir) *)
(* lndir command whihc is a unix command replicates the directory strucutre of folders and sub-folders between source and destination folders
excluding the files but places the symbolic links of the files instead in the destination directories *)
(* unix lndir man page (http://www.xfree86.org/4.3.0/lndir.1.html) *)
第2步:
set sourceFolder to choose folder with prompt "Choose Source Folder"
(* get a prompt windows to choose source folder *)
tell application "Finder"
set allSymLinks to entire contents of sourceFolder
(* define a variable allSymlinks so that every file in that folder is scanned for its kind and arrayed *)
repeat with aSymLink in allSymLinks
(* repeat the following for every file found (as a variable 'aSymLink') in the array made ('allSymLinks')*)
if kind of aSymLink is alias then
(* if the file type is an alias (which is the same for both symbolic link and a mac finder alias) then *)
set posixPath to POSIX path of aSymLink
(* set variable to the POSIX path of that file (as it is required for apple script) *)
move aSymLink to trash
(* move that symbolic link file to trash *)
set aliasPath to POSIX file of posixPath as alias
(* set a variable 'aliasPath' while making a POSIX file (a mac finder alias file)
with the POSIX path acquired from the symbolic link before we moved it to trash *)
end if
end repeat
end tell
(* this script is an intermediary step only because the apple script would't work when we simply write the 'if' condition with kind is alias then...
as though the kind of Symbolic Link is alias, for some reason apple script didn't use it as it would with an original mac finder alias,
so we are converitng it to mac finder type alias using the POSIX path*)
(* Probably the reason might be that apple script can only fetch the original file if the path is of POSIX style *)
第 3 步:
set sourceFolder to choose folder with prompt "Choose Source Folder"
(* get a prompt windows to choose source folder *)
tell application "Finder"
set allAliases to entire contents of sourceFolder
(* define a variable allAliases so that every file in that folder is scanned for its kind and arrayed *)
repeat with anAlias in allAliases
(* repeat the following for every file found (as a varaible 'anAlias') in the array made ('allAliases')*)
if class of anAlias is alias file then
(* if the file's class type is an alias then *)
set originalFile to original item of anAlias
(* defining originalFile to the original file the alias is pointing to *)
set containerFolder to container of anAlias
(* defining contianerFolder to the folder the alias is pointing to *)
move anAlias to trash
(* deleting the alias to trash *)
move originalFile to containerFolder
(* moving the original file to the folder *)
end if
end repeat
end tell
(* Apple Script didn't work when like in the previous step's script If i wrote 'kind is alias', before I changed them to POSIX style alias,
which apple script seems to work with *)
(* Probably the reason might be that apple script can only fetch the original file if the path is of POSIX style *)
我希望有一个应用程序来解决所有这些问题
但那时我永远不会学到所有这些。
希望这对每个有需要的人都有用。
再会