Reputation: 4010
I've tried adding quotation marks around filepaths, and replacing quotation marks with 0x22. Also tried other variables and they all return the same kind of error. Tried one equal, two equals, all capitals... Everything looks right, but I don't understand why it's not working, would appreciate any help. Thanks.
set source=N:\Movies\
set target=M:\Movies\
forfiles /P "%source%" /C "cmd /c if @isdir==TRUE ( mklink /d 0x22%target%\@file\0x22 @path ) else ( mklink 0x22%target%\@file\0x22 @path )"
This is the error:
ERROR: Invalid argument/option – '@isdir==TRUE'.
Upvotes: 2
Views: 7550
Reputation: 2299
The selected answer doesn't work as the comments say. Remove the quotes around %source%
and it will work (tested):
set source=N:\Movies\
set target=M:\Movies\
forfiles /P %source% /C "cmd /c if @isdir==TRUE echo @path"
If you test that with the quotes around %source%
, you'll get that same error. Basically the quotes screw up your @path
even if you're not using the variable and simply putting the path itself. Leave the quotes off.
Upvotes: 5
Reputation: 4063
you need to treat the @isdir as a string
@isdir Returns "TRUE" if a file type is a directory,
and "FALSE" for files.
So: @isdir=="TRUE"
Source: http://ss64.com/nt/forfiles.html
Upvotes: 1