Copying HTML files & assosiated dirs to separated dirs

Suppose that you have tow HTML file called A.html & B.html. I want move each HTML file and its associated directory to a second directory named with the HTML file name. i.e. A.html & A_files be moved to a directory named A and B.html & B_files be moved to a directory named B.

I wrote the following code for this aim:

@filesonly 
@nofilenamequoting
@nodeselect
@firstfileonly
dopusrt /cmd Select "{o|noext|escwild}_files" 
dopusrt /cmd Copy MOVE HERE CREATEFOLDER = "{o|noext|escwild}"

The above code worked, but have a bad problem.

I cannot select all of my HTML files and apply the code to them, yea!, I must select each HTML file separately and apply the code to it and then select next html file and apply the code to it again and ...

How can I apply this code to all of my selected HTML files separately one by one?

Best Regards

I created a test directory (see screenshot below). I did't test it extensively, but this code seems to work (you don't have to select the html files separately):

SELECT *.html
@SET name = {file$|noext}
COPY MOVE HERE CREATEFOLDER {$name}
COPY MOVE "{$name}_files" TO ".\{$name}"

Wooow! :smiley: What an intelligently code. I'm very appreciative of your help.

I deleted the first line and now I can apply it just on my selected HTMLs. I tested your code on 387 file without any problem, but a very little problem: If a HTML file have not any associated file, DOpus show an error message during processing 4th line of the code and as far as I know, there is no way to disabling DOpus error messages just for a specific command :cry: (I hope someone tell me I am wrong in this context).

Best Regards

This solves the problem (I added CreateFolder NAME "{$name}_files"):

@SET name = {file$|noext}
CreateFolder NAME "{$name}_files" 
COPY MOVE HERE CREATEFOLDER {$name}
COPY MOVE "{$name}_files" TO ".\{$name}" 

It creates an empty folder when the html file doesn't have an associated folder, so DOpus doesn't show the error message anymore when executing the last line of the code.

Adding READAUTO=no to the CreateFolder line is a good idea here:

@nofilenamequoting 
@SET name = {file$|noext}
CreateFolder READAUTO=no NAME "{$name}_files"
COPY MOVE HERE CREATEFOLDER {$name}
COPY MOVE "{$name}_files" TO ".\{$name}"

I put @nofilenamequoting in as well as it looks like quotes in the name may have been doubled-up with the quotes in the command.

Thank Christiaan & Leo for all your golden helps.

Sincerely Yours

Why this code is not worked under new version?

It still seems to work fine here.

Which "new" version? What happens?

Thanks to reply dear Leo.
Version: 9.5.6.0

  1. When selected files have simple names (e.g. 1.htm, 2.htm, 3.htm), after selecting 1.htm, 2.htm, 3.htm and executing above code on them, instead of moving each file and its associated directory to separated directories (i.e 1.htm & 1_files -> 1, 2.htm & 2_files -> 2 and 3.htm & 3_files ->3), a directory named 1 is created and 1.htm, 2.htm and 3.htm are moved to it (associated directories are not moved).

  2. When there is some space in file names (e.g. "a b c.htm"), I receive the following error:
    The system cannot find the file specified.(2)

  3. I changed the previous code to this code

@nofilenamequoting
CreateFolder READAUTO=no NAME "{file$|noext|escwild}_files"
COPY MOVE HERE CREATEFOLDER "{file$|noext|escwild}"
COPY MOVE "{file$|noext|escwild}_files" TO ".\{file$|noext|escwild}"

The 1 & 2 problems were solved, but a new problem was appeared. Now when there is a ' in file name, the problem 1 is appeared and ' is changed to '' too.

The latest one on the torrent sites, presumably.

I found the problem. I delete '|escwild' of the above code, everything went right.

The button in my post should already handle spaces in names and you should not need to use escwild. Maybe you'be got the button set to DOS Batch Type or something.

I was not changed anything in my DOpus, except the version. As I told, after modifying the code to the last one, the problem was solved. In any case, thanks to your attention.