Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


next1991
2019-01-23T13:14:13Z
Maybe i got an easy Problem... i hope someone can help me.

I got one directory (A) with a lot of files... for example:

c:\test
23012019_XXXXXX.txt
23012019_YYYYYY.txt
24012019_XXXXXX.txt
25012019_XXXXXX.txt

I want to move it in a second directory (B)... That's not the Problem...
If i do this with "List files" + SUBSTRING it looks like:

c:\test\23012019_Folder\23012019_XXXXXX.txt
c:\test\23012019_Folder\23012019_YYYYYY.txt
c:\test\23012019_Folder\24012019_XXXXXX.txt
c:\test\23012019_Folder\24012019_XXXXXX.txt


The task should create some sub directories... (actually i tried it with a substring, but this doesnt work in my case.)

c:\test\23012019_Folder\23012019_XXXXXX.txt
c:\test\23012019_Folder\23012019_YYYYYY.txt
c:\test\24012019_Folder\24012019_XXXXXX.txt
c:\test\25012019_Folder\25012019_XXXXXX.txt

How can i do this? I hope someone can help me. Thx




Sponsor
Forum information
Support
2019-01-23T16:29:23Z
This require some development changes but this has currently been passed to developers so we hope we can deliver this functionality within two weeks. The change we do is to be able to work with the current file name when creating target folder.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Gary_W
2019-01-23T16:29:35Z
If I understand you right, you need to create a folder with the date of each file and then move the file into it. You can do this with 2 tasks and a loop.

First create a list file task. To ensure grabbing the right files, I like to use a regular expression and make the match as tight as possible to ensure I only grab the right files but you may not have to. For this case I'd use \d{8}_.{6}\.txt for the include file mask which matches filenames starting with 8 digits followed by an underscore followed by 6 characters then a literal dot and "txt". Like I said, you may not need to get this strict. For output settings check to output file name only.

Next create a copy file task. The include file mask will be the current line of the loop (which will loop through the file list from the first task) which we haven't added yet so you'll have to trust me here and enter {LOOP(CurrentValueXLine)}. For the destination folder I build it using the job variable I created for the main folder where the files will be found that I called JobWorkingDir. To this I append the leftmost 8 characters of the filename as found by the loop (using the STRING-LEFT function) and append to the the string "_Folder\" so the while thing looks like this: {JOB(Active|Variable|JobWorkingDir)}\{STRING(Left|{LOOP(CurrentValueXLine)}|8)}_Folder\ The destination filename will be the filename from the loop: {LOOP(CurrentValueXLine)}. If you want to move instead of copy, be sure to check the "Delete source file after copy" box at the bottom.

Now go to the edit job window and add a loop. Start task is the list files task and end task is the copy files task. In the settings tab, check the "For each x in y" and for the value in the "For each row x in" box you'll need to put the stdout for the active task for the list files task: {TASK(Active|StdOut)}.
Support
2019-01-23T16:30:38Z
Originally Posted by: Gary_W 

If I understand you right, you need to create a folder with the date of each file and then move the file into it. You can do this with 2 tasks and a loop.

First create a list file task. To ensure grabbing the right files, I like to use a regular expression and make the match as tight as possible to ensure I only grab the right files but you may not have to. For this case I'd use \d{8}_.{6}\.txt for the include file mask which matches filenames starting with 8 digits followed by an underscore followed by 6 characters then a literal dot and "txt". Like I said, you may not need to get this strict. For output settings check to output file name only.

Next create a copy file task. The include file mask will be the current line of the loop (which will loop through the file list from the first task) which we haven't added yet so you'll have to trust me here and enter {LOOP(CurrentValueXLine)}. For the destination folder I build it using the job variable I created for the main folder where the files will be found that I called JobWorkingDir. To this I append the leftmost 8 characters of the filename as found by the loop (using the STRING-LEFT function) and append to the the string "_Folder\" so the while thing looks like this: {JOB(Active|Variable|JobWorkingDir)}\{STRING(Left|{LOOP(CurrentValueXLine)}|8)}_Folder\ The destination filename will be the filename from the loop: {LOOP(CurrentValueXLine)}. If you want to move instead of copy, be sure to check the "Delete source file after copy" box at the bottom.

Now go to the edit job window and add a loop. Start task is the list files task and end task is the copy files task. In the settings tab, check the "For each x in y" and for the value in the "For each row x in" box you'll need to put the stdout for the active task for the list files task: {TASK(Active|StdOut)}.



Great workaround Gary! We will still implement the support for being able to use the current file name.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
next1991
2019-01-24T09:22:43Z
next1991
2019-01-24T12:51:55Z
Hm... i got a new Problem.

If i start i just start the first "list file" Task... and then the fulljob, it works.

but if i reset the Job and start directly the full Job... nothing happens.

what is to do now ?
Gary_W
2019-01-24T13:52:26Z
I'm afraid there's not enough info. Something has to happen! is there an error on the first task? Could you post screen shots of how your job and tasks are set up?
next1991
2019-01-24T14:25:00Z
image1_loop.png image2_loop.png image3_loop.png image4_loop.png

Doesn't work if the job is resetted. I have to start the list file task manually. :/ do u need more pictures? I didnt get an error message.
Gary_W
2019-01-24T15:00:18Z
How about the list files task since that's the starting point. Is it finding files? Go back to basics and double-check job variables and make sure they are pointing to the right place, etc. That's what I do anyway when things go suddenly really strange. Restart your client too. Sometimes I have experienced the activate/deactivate menu item stops working or the icons don't change state and a restart fixes that.
next1991
2019-01-24T15:07:26Z
image5_loop.png

the Task is finding some files. I have to start the task manually.

mh, i already restarted the client a few times.

do u got any ideas?
Gary_W
2019-01-24T15:11:57Z
One last thing to try. In the loop settings, for each row x in, instead of using stdout of the active task, use the direct ID STDOUT.
next1991
2019-01-24T15:14:30Z
I already tried this 😞
Gary_W
2019-01-24T15:17:59Z
On the Edit job window, do you have "run tasks in order" checked?
Gary_W
2019-01-24T15:27:30Z
Wait the job log says the loop is not finding any output from list files. Did you reset your test files in the folder after running manually?
next1991
2019-01-24T15:34:10Z
Yes, i did.

the second Task just copy the files without delete. The files are still at the same place.


All Jobs got the state "no output". Manually is fine, full Job isnt fine. :/
Gary_W
2019-01-24T15:38:56Z
How are you running the full job? Right-click on it and select Run job 'Archivierung'? Reset job resets the screen fields and internal counters, timers, etc but does not run it. If this isn't it, I'm out of ideas.
next1991
2019-01-25T08:24:07Z
Yes, this is the way.

I created the Job again... without copy and clone... still doesnt work.

The job doesnt work with the loop. Without the loop, the tasks are starting all the time... 😞
Gary_W
2019-01-25T15:11:31Z
I'm on 8.3.5 and it works for me with a loop. I am out of things to try.
Scroll to Top