1

Problem:

Files get pulled automatically from my emails to a folder on my Google Drive. The files are automatically given a name, which was the subject of the email, e.g. "Beach". Multiple files can thus have the same name if emails have the same subject name.

Once the files have landed in Google Drive, I want to move the files, say the ones called "Beach", to another folder called "Beach".

What is the best way to do this? I have tried using scripts, lists of folders/ID/file names etc in spreadsheets, yet can't quite get it.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
jdh
  • 11
  • 1
  • 3

2 Answers2

1

According to this article, you can use Google Apps Scripts to move files across folders.

function moveFiles(source_folder, dest_folder) {

  var files = source_folder.getFiles();

  while (files.hasNext()) {

    var file = files.next();
    dest_folder.addFile(file);
    source_folder.removeFile(file);

  }
}

Here are some related threads which might help:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

This is what I use and it works well The_unique_File_id is the part after drive.google.com/drive/folders/ the letters and numbers

function copyFiles(source_folder, dest_folder) {

  var source_folder = DriveApp.getFolderById('The_unique_File_id'); 
  var dest_folder = DriveApp.getFolderById('The_unique_File_id'); 
  var files = source_folder.getFiles();

  while (files.hasNext()) {

    var file = files.next();
    dest_folder.addFile(file);
    source_folder.removeFile(file);

  }
}
user7291698
  • 1,972
  • 2
  • 15
  • 30