0

I really hope that you will help with this. Well, I have a folder full of files which has name like this :

AZERRKDKD_00000.csv AZERKRJFJDD_0000.csv …

I am looking for a script that can help me to create new folder in another directory and paste this file. Here is the example:

AZERRKDKD[folder]

AZERRKDKD_00000.csv (file)

AZERKRJFJDD [folder]

AZERKRJFJDD_0000.csv (file)

Moreover, if the folder already exists, I just want the file to be paste in the exact folder:

Can you please help me by writing me a script ?

Thanks in advance,

Community
  • 1
  • 1
Sara ATINE
  • 23
  • 2
  • 1
    There are two stages to this you can try. First is to write some code just to list all of the files in a particular folder. Then with this code, you can split the name and check if the folder exists (if not create it), then move the file into this folder. – Nigel Ren Jun 11 '20 at 08:43
  • Hello ! Thanks for you response, How can I list all the files and split it ? – Sara ATINE Jun 11 '20 at 13:33
  • Start with https://stackoverflow.com/questions/15774669/list-all-files-in-one-directory-php. – Nigel Ren Jun 11 '20 at 13:43
  • I have my list now :) Do I need to use the mention explode to split it ? – Sara ATINE Jun 11 '20 at 13:57
  • https://stackoverflow.com/questions/24661423/php-get-everything-in-a-string-before-underscore, then https://stackoverflow.com/questions/5425891/how-do-i-check-if-a-directory-exists-is-dir-file-exists-or-both – Nigel Ren Jun 11 '20 at 14:00

0 Answers0