@echo on
for /F "delims=*" %%F in ('xcopy /S /L "E:\DATA\*.jpg" \ ^| findstr /v File^(s^)') do (
xcacls "%%F" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
attrib -a "%%F"
)
ASKER
ASKER
ASKER
ASKER
ASKER
@echo on
for /F "delims=*" %%F in ('dir /a:a /s /b E:\DATA\*.jpg') do (
xcacls "%%F" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
attrib -a "%%F"
)
The dir I provided originally was wrong. it listed all files having the archive attribute NOT set.Get-ChildItem E:\Data -include *.jpg |
? { $_.Attributes -band [System.IO.FileAttributes]::Archive } |
% {
xcacls "$_.FullName" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
$_.Attributes = $_.Attributes -bxor [System.IO.FileAttributes]::Archive
}
As you can see, it is not really different, processing is very similar. The full .NET method to replace xcacls is more complex, and would not help to change speed either, so I just left the command.
ASKER
xcacls "E:\DATA\IMG_0001.JPG" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
attrib -a "E:\DATA\IMG_0001.JPG"
)
ERROR: No mapping between account names and security IDs was done.
PS C:\IT\SCRIPTS> ".\test3.ps1"
.\test3.ps1
PS C:\IT\SCRIPTS>
.\test.ps1
& ".\test.ps1"
& '.\test.ps1'
ASKER
PS C:\IT\SCRIPTS> .\test3.ps1
PS C:\IT\SCRIPTS>
Get-ChildItem E:\Data -include *.jpg -recurse |
? { $_.Attributes -band [System.IO.FileAttributes]::Archive } |
% {
xcacls "$_.FullName" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
$_.Attributes = $_.Attributes -bxor [System.IO.FileAttributes]::Archive
}
ASKER
PS C:\IT\SCRIPTS> .\test3.ps1
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
ERROR: The system cannot find the file specified.
PS C:\IT\SCRIPTS>
ASKER
PS C:\IT\SCRIPTS> .\test3.ps1
ERROR: No mapping between account names and security IDs was done.
PS C:\IT\SCRIPTS>
ASKER
Get-ChildItem E:\Data -include *.jpg -recurse |
% {
xcacls "$($_.FullName)" /P "Authenticated Users:R" "Domain\Administrator:F" "SYSTEM:F" "Photo Admins:F" /Y
$_.Attributes = $_.Attributes -bxor [System.IO.FileAttributes]::Archive
}
ASKER
ASKER
ASKER
Kernel and system programming is the process of creating the software necessary for a computer or device to function and operate other programs. Some operating systems (such as Microsoft Windows) are proprietary, but others, such as the various Linux distributions, are open source.
TRUSTED BY
Instead of XCopy and findstr, I would use dir /a:-a /s /b E:\DATA\*.jpg - but don't think that is faster.
In PowerShell the only pro is that the files get processed as soon as they are seen in the directory. The batch file above has first to process the complete directory, and then applies changes. This is not faster, but allows the process to get interrupted at any point, and restarting should be reasonable fast.