Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to move multiple files of 1 folder to multiple folders?
#1
Introduction: Hi, I have multiple files in one folder T and want to move part by part of them into multiple folders i.
Example: Say, folder T has 15 .txt files and I want to move from file 1-5 into folder 1, then 6-10 into folder 2 and 11-15 into folder 3.
What I have done so far? I wrote the following lines which was supposed to generate i-number of folders and move the k-files:

Code:
Copy      Help
int nfi=5    ;;number of files per folder
int nfo=3    ;;number of folders

int i j=nfo+1
for(i 1 j)
    out i
    mkdir "$Desktop$\{i}" ;; Make i-ten folder
    int k l=(i*nfi)+1
    for(k ((i*nfi)-(nfi-1)) l)
        out k    
        ren "$Desktop$\T\{k}.txt" "$Desktop$\{i}" ;; Move k-ten file from folder T to folder i

Problems:

1) The folders are not being created, instead of that it creates only one folder {i}.
2) Even if the folder i exist, I obtain an error that it cannot move the file.
3) Now, let's assume the syntax problems are fixed and the code is doing it right, this means it would move file by file in each run of i. Question, is there a way to select directly the range of files to move to avoid doing it file by file? Something like:
Code:
Copy      Help
ren "$Desktop$\T\ {k}.txt to {k+4}.txt" "Desktop$\{i}"

So I wonder if someone could help me to correct these lines or suggest a new way to do the same.
I thank you in advance for your help

Emerson
#2
I dont clearly see where u get the filenames so lets say they are just numbers (1.txt, 2.txt, 3.txt)


Macro Macro2
Code:
Copy      Help
int nfi=5   ;;number of files per folder
int nfo=3   ;;number of folders

int i
for i 1 nfo+1
,mkdir F"$Desktop$\Folder_{i}"
,rep nfi
,,_i+1
,,ren F"$Desktop$\T\{_i}.txt" F"$Desktop$\Folder_{i}"
#3
p.s. Your code also works just need to use operator F in lines with enclosed variables.

Macro Macro2
Code:
Copy      Help
int nfi=5   ;;number of files per folder
int nfo=3   ;;number of folders

int i j=nfo+1
for(i 1 j)
,out i
,mkdir F"$Desktop$\{i}" ;; Make i-ten folder
,int k l=(i*nfi)+1
,for(k ((i*nfi)-(nfi-1)) l)
,,out k  
,,ren F"$Desktop$\T\{k}.txt" F"$Desktop$\{i}" ;; Move k-ten file from folder T to folder i


Forum Jump:


Users browsing this thread: 1 Guest(s)