Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

To create folder and move a specific number of files

Community Beginner ,
Mar 30, 2017 Mar 30, 2017

Hello Everyone,

The below screen grab is my existing folder.

existingfolder.jpg

Step 1: I would like to create a folder named with the file naming given above (chapter_001). The new folder looks like, chapter_001_01.

Step 2: I would like to move above files (3 files) to newly created folder.

Step 3: Again, create a folder named with the file naming given above (chapter_004). The new folder looks like, chapter_004_01.

Step 4: Again, move above files (3 files) to newly created folder.

As I am a beginner for this Javascript, I am unable to think that is possible to make a script to run this process.

It would be great if you could help me know whether this is possible for JS.

Thank you!

TOPICS
Actions and scripting
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 03, 2017 Apr 03, 2017

Hi sarshan​,

same principle as in your last thread:

To create folder

  1. // for Windows 
  2. var folder1 = Folder("/x/qa/Team/Saravanan"); 
  3. if (!folder1.exists) {folder1.create();}

rewritten

// for Windows

var curFolder = new Folder("/x/qa/Team/Saravanan/mergefiles/guna");

Have fun

Translate
Adobe
Community Expert ,
Mar 30, 2017 Mar 30, 2017

Why would you want to do that in Photoshop?

JJMack
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 30, 2017 Mar 30, 2017

Try this script. You need to change line one to the path of your current folder:

var curFolder = new Folder(Folder.desktop + '/Current Folder')//Change the path to wherever your current file is located

var mask = '*.xhtml';

var fList = curFolder.getFiles (mask);

var counter = 1;

var nextFolder;

var nextFolderName;

for(var i=0;i<fList.length;i++){

    if(counter ==1){

        nextFolderName = fList.name.split('.')[0];

        nextFolder = new Folder(curFolder + '/' + nextFolderName + '_01');

        if(!nextFolder.exists){nextFolder.create()};

        }

    counter++;

    if(counter ==4){counter = 1};

    fList.copy(nextFolder +'/' + fList.name);

    fList.remove();

    }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 03, 2017 Apr 03, 2017

Thank you for sharing this script.

I would like this script to run in Windows rather than Mac and also like to add the location mentioned below.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 03, 2017 Apr 03, 2017

Hi sarshan​,

same principle as in your last thread:

To create folder

  1. // for Windows 
  2. var folder1 = Folder("/x/qa/Team/Saravanan"); 
  3. if (!folder1.exists) {folder1.create();}

rewritten

// for Windows

var curFolder = new Folder("/x/qa/Team/Saravanan/mergefiles/guna");

Have fun

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 04, 2017 Apr 04, 2017

Thank you

It's very useful

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 04, 2017 Apr 04, 2017

You're welcome.

Credits should go to Chuck Uebele

sarshan​, did you tried his script snippet? Does it works for you?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 05, 2017 Apr 05, 2017

Yes, It works perfectly.

Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 07, 2017 Apr 07, 2017

Schubser,

Is that possible to assign the location and number of files manually?

I want to assign the location and number of files manually because the numbers is not constant.

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2017 Apr 07, 2017

give us examples please

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 12, 2017 Apr 12, 2017
LATEST

As given below, I want to set the location and number of files to be moved as user input.

For more example:

1. Once I hit the script using panel will ask as user input.

2. After I enter the file name, a folder needs to be created.

3. Again the script will ask how many files to moved with created folder.

4. As soon as I give the numbers, the files to be moved.

I don't know if this possible in adobe scripting. But, If it works as needed, it would be much appreciated.

The below script does that what I need but I can't set the location and the number of files through user input.

Cheers

  1. var curFolder = new Folder(Folder.desktop + '/Current Folder')//Change the path to wherever your current file is located 
  2. var mask = '*.xhtml'
  3. var fList = curFolder.getFiles (mask); 
  4. var counter = 1
  5. var nextFolder; 
  6. var nextFolderName; 
  7. for(var i=0;i<fList.length;i++){ 
  8.     if(counter ==1){ 
  9.         nextFolderName = fList.name.split('.')[0]; 
  10.         nextFolder = new Folder(curFolder + '/' + nextFolderName + '_01'); 
  11.         if(!nextFolder.exists){nextFolder.create()}; 
  12.         } 
  13.     counter++; 
  14.     if(counter ==4){counter = 1}; 
  15.     fList.copy(nextFolder +'/' + fList.name); 
  16.     fList.remove(); 
  17.     } 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines