本文介绍了使用AppleScript我想在文件夹中的所有文件移动到根文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图让一个脚本到一个文件夹中的所有文件移动到根文件夹中包含每个子文件夹中。我不想做一个新的文件夹,只需将它移动到根目录下。

我希望能够选择文件夹,然后在行动上特定的文件夹只完成了。

原因是组织,我确切的情况是我有超过电影的结核病和文件夹中的文件夹内有文件。我想在根文件夹所有这些文件,这样我可以组织他们我认为合适。此外,我想复制和删除,而不是移动作为研究已经使我相信是最好的途径。

好吧,我不能拿到剧本的工作,但我没有找到一个链接,不正是我在寻找一个工作流程:


我在上面保持本节的历史而言,一切都在这个虚线之间更新是什么,我会编辑后已经删除

我曾尝试下面这个脚本进行逆向工程,我发现了,但是,我不能得到它的工作就像我想。任何及所有帮助将非常apprieciated,我是很新的脚本和我来的岩石。

第二尝试
告诉应用程序发现者
        集main_folder到(选择带有提示的文件夹,选择主文件夹)
        设置sub_folders为main_folder的文件夹
        在sub_folders each_folder重复
        移动(each_folder的每一个文件)来替换main_folder
        重复结束
        尝试
        年底试
        最终告诉

1日尝试
告诉应用程序发现者
设置sourceFolder到文件夹打动我 - 磁盘的嗒嗒等。
 我moveFilesFrom(sourceFolder)
 最终告诉

在moveFilesFrom(thisFolder)
告诉应用程序发现者
设置filesToMove为thisFolder的每个文件
与å文件重复filesToMove
 移动å文件到文件夹destFolder
重复结束
设置子文件夹(thisFolder的每个文件夹)
与aFolder重复子文件夹中
我moveFilesFrom(aFolder)
重复结束
告诉结束
最终moveFilesFrom

取景器超时当我使用它包含了大量的信息和子文件夹AA文件夹,我昨天用它在一个测试文件夹,并没有问题,但相当小的工作。

我现在利用adayzdone提供的这个脚本

  MyFolder的集到(选择带有提示的文件夹,选择主文件夹)
    告诉应用程序发现者
    设置myfiles的得到的那种≠的每一项(MyFolder文件夹中的所有内容)文件夹
    移动myfiles的到MyFolder中
    告诉结束



解决方案

您可以尝试这样的事情:

 设置为MyFolder文件(路径桌面文本)及testFolder
告诉应用程序发现者
    设置MYFILES得到的那种≠的每一项(MyFolder文件夹中的所有内容)文件夹
    移动MYFILES到MyFolder中
告诉结束

,也可以使用shell脚本像LRI建议:

 集MyFolder中以引用的形式(选择带有提示的文件夹,选择主文件夹)的POSIX路径
做shell脚本CD&放大器; MyFolder中&安培; 发现型的F -exec MV {}。&放大器; MyFolder中&安培; \\\\;

I have been trying to make a script to move every file within a folder to the root folder to include every sub folder. I don't want to make a new folder just move it to the root folder.

I want to be able to select the folder and then the action be completed on that specific folder only.

The reason is for organization, my exact situation is I have over a TB of movies and there's files within folders within folders. I want all those files on the root folder so that I can organize them how I deem fit. Also I would like to copy and delete instead of move as research has led me to believe is the best route.

Well I couldn't get the script to work but i did find a link to a workflow that does exactly what I'm looking for:

http://www.macworld.com/article/1160660/automator_filesfromsubfolders.html


I updated above keeping this section for history purposes, everything in between this dotted lines is what I would have deleted after editing

I have tried to reverse engineer this script below, that i found but, I just can't get it to work like I want to. Any and all help will be much apprieciated, I am very new to scripting and I have come to a rock.

2nd Attempttell application "finder" set main_folder to (choose folder with prompt "choose the main folder") set sub_folders to folders of main_folder repeat with each_folder in sub_folders move (every file of each_folder) to main_folder with replacing end repeat try end try end tell

1st Attempttell application "Finder"set sourceFolder to folder "MOVE ME" -- of disk "blah", etc. my moveFilesFrom(sourceFolder) end tell

on moveFilesFrom(thisFolder)tell application "Finder"set filesToMove to every file of thisFolderrepeat with aFIle in filesToMove move aFIle to folder destFolderend repeatset subFolders to (every folder of thisFolder)repeat with aFolder in subFoldersmy moveFilesFrom(aFolder)end repeatend tellend moveFilesFrom

The finder times out when I use it on a a folder containing a lot of information and sub-folders, I used it on a test folder yesterday and it worked with no problem but substantially smaller.

I am now using this script provided by adayzdone

    set myFolder to (choose folder with prompt "choose the main folder")
    tell application "Finder"
    set myfiles to get every item of (entire contents of folder myFolder) whose kind ≠ "Folder"
    move myfiles to myFolder
    end tell


解决方案

You can try something like this:

set myFolder to (path to desktop as text) & "testFolder"
tell application "Finder"
    set myFiles to get every item of (entire contents of folder myFolder) whose kind ≠ "Folder"
    move myFiles to myFolder
end tell

or you can use a shell script like Lri suggested:

set myFolder to quoted form of (choose folder with prompt "choose the main folder")'s POSIX path
do shell script "cd " & myFolder & "; find . -type f -exec mv {} " & myFolder & " \\;"

这篇关于使用AppleScript我想在文件夹中的所有文件移动到根文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:24