Pdfs with a name including the variable

Hello, I’m a bit lost, I’m trying to do this and I can’t create it in app server

I have an import folder in which I have pdfs with a name including the variable that will be used to classify them in a specific directory.

Example :

2000011-764473-146613.pdf
2000113-764682-146608.pdf

I test if pdf are present in the import directory
(in the folder here are the files present:
2000011-764473-146613.pdf
2000113-764682-146608.pdf

if pdf are present then:
for each file I retrieve the variable, here for the first file 146613. I check that the content/146613 directory exists if it does not I create it if it exists I move the le to the content/146613 directory

then I do the same for the second file.

I was thinking of making a listing of the PDF files present in the import directory, to extract the file name and the variable, but I don’t know how to do it, any idea?

Thanks

This is easy, you have to play with the Data formatter, something like this:

"2000011-764473-146613.pdf".split("-")[2].split(".")[0]
// returns "146613"

Don’t worry if you didn’t understand this yet, someone can explain in better detail later

I’ve just tried to do this in Wappler’s Set Value, had a bit of trouble with the data formatter. You probably need to type that directly in the code section

Hi Apple Thanks for your help

I tried to put the steps in the image, it does not work of course, I have a 404 error

Would there be logs? who would tell me when it bugs?

Thank you

I think I have found the bug because the program is in a subfolder, I’ll come back to you,

I have a problem, it tells me that the folder does not exist yet I ask it to test its existence and if not to create the directory, but I always have the same error

an idea?

Thanks

  1. {code: 0, file: “/var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/modules/fs.php”,…}

  2. code: 0

  3. file: “/var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/modules/fs.php”

  4. line: 178

  5. message: “Folder doesn’t exist. (/var/www/vhosts/paritys.com/global.paritys.com/data/content/146613/2000011-764473-146613.pdf)”

  6. trace: “#0 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(195): modules\fs->move()\n#1 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(159): lib\App->execSteps()\n#2 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(127): lib\App->execSteps()\n#3 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/modules/fs.php(76): lib\App->exec()\n#4 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(195): modules\fs->direxists()\n#5 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(159): lib\App->execSteps()\n#6 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(127): lib\App->execSteps()\n#7 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/modules/core.php(69): lib\App->exec()\n#8 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(195): modules\core->repeat()\n#9 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(159): lib\App->execSteps()\n#10 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(127): lib\App->execSteps()\n#11 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnectLib/lib/App.php(94): lib\App->exec()\n#12 /var/www/vhosts/paritys.com/global.paritys.com/dmxConnect/api/Envoi_factures/Tri_envoi.php(8): lib\App->define()\n#13 {main}”

I can see in the error that he tries to create the folder with the name of the file instead of taking the variable that I ask him but I can’t find it

ok its good

Glad you managed to solve it! If you experience any further problems feel to post it