Windows 10: Robocopy automatically taking source directory as the script file directory

Discus and support Robocopy automatically taking source directory as the script file directory in Windows 10 Gaming to solve the problem; Synopsis:- Script file directory name -> PowerShellScripts in Desktop in local C:\...- Script file name -> Dbackup.ps1- Intended source for mirroring... Discussion in 'Windows 10 Gaming' started by AKSJ007, Jul 25, 2022.

  1. AKSJ007 Win User

    Robocopy automatically taking source directory as the script file directory


    Synopsis:- Script file directory name -> PowerShellScripts in Desktop in local C:\...- Script file name -> Dbackup.ps1- Intended source for mirroring -> D:\ a partition on local hard disk- Intended destination for mirroring -> F:\D_LAPTOP_BACKUP_ ... F: is external SSD connected via USBScript:[string]$currentDirectory = Get-Location[DateTime]$currentDateTime&n

    :)
     
    AKSJ007, Jul 25, 2022
    #1

  2. Script can copy file directory in one spot but not the other

    On drive E: on a Windows Server, I have directory "test". And then maybe 4 more directories down I have directory "fred". My script runs in a different tree under test. It points a to the fred directory which contains files, and sub directories with files. The script looks for files with a certain extension, makes a backup of them, then edits the original files. Now this works for all of the files directly in the "fred" directory. But the files in any of the sub directories of fred, give an issue with copying the file. As a test, I copied fred and all its contents to E:\. I adjusted the script to look at E:\Fred, and everything worked fine. The originals were copied, and edited as expected.

    I compared permissions between E:\Fred and E:\test\..\..\..\fred. they're basically the same. They both have a checkmark in read only(which only resets itself after i uncheck it). The only minor difference was that E:\test\..\..\..\fred didnt have a couple of special permissions for the Users group. This involved, modify, dir traversal, read and execute. I gave those permissions but still no luck.
     
    Hybrid_theory, Jul 25, 2022
    #2
  3. Script can copy file directory in one spot but not the other

    Haha yeah its fred. sorry its 8am and my mind isnt fully functional yet. There is an error along side the one my script posts: No such file or directory at script line 20.(which is the copy line). I pointed the script to one of the sub directories exactly, still wouldnt copy. I created a new sub dir, and copied some of the files from the main directory into the new directory, those wouldnt copy either.

    script:
    Code: #!/usr/bin/perl -w use strict; use warnings; use File::Find; use File::Copy; my $directory="..\\..\\doc\\xsd"; find (\&subr, $directory); sub subr { foreach ($File::Find::name=~/(.*)\.xsd$/) { my $filetobecopied = $File::Find::name; my $newfile = $1 . ".origxsd"; copy($filetobecopied, $newfile) or die "$File::Find::name cannot be copied $!"; chmod 0777, $File::Find::name; open (FILE, "<", $File::Find::name) or die "Cannot open file $!"; print $File::Find::name. "\n"; local $/; my $file=<FILE>; $f=~s/<!--[\w\W^]*?-->//gi; close FILE; open (OUT, ">", $File::Find::name) or die "Cannot write to file $!"; print OUT $f; close OUT; chmod 0444, $File::Find::name; } }[/quote] thanks kreij
     
    Hybrid_theory, Jul 25, 2022
    #3
  4. Robocopy automatically taking source directory as the script file directory

    Script can copy file directory in one spot but not the other

    It's having trouble copying any of the files in the sub directories of frank. All the files directly under frank are properly backed up and the originals are properly edited.

    The script runs using a foreach, looking for any file that ends with a specific extension, in the directory specified. It uses File::find to locate each file. The script first copies the file and adds "orig" to the extension name, for example the file is .origpy instead of .py. The original file is changed from read only to full write permissions. Then it is opened for reading, all is read into memory except the comments. The file is closed. The file is opened for writing. Everything from the file in memory is written to file. The file is closed, and changed back to read only.

    This works great in Linux. I tried it in XP, its fine as well. just something about the directory structure on this server that wont let it work for the sub directories in frank.
     
    Hybrid_theory, Jul 25, 2022
    #4
Thema:

Robocopy automatically taking source directory as the script file directory

Loading...
  1. Robocopy automatically taking source directory as the script file directory - Similar Threads - Robocopy automatically taking

  2. Why robocopy only copy directories but not files?

    in Windows 10 Network and Sharing
    Why robocopy only copy directories but not files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?Here is the command I...
  3. Why robocopy only copy directories but not files?

    in Windows 10 Gaming
    Why robocopy only copy directories but not files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?Here is the command I...
  4. Why robocopy only copy directories but not files?

    in Windows 10 Software and Apps
    Why robocopy only copy directories but not files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?Here is the command I...
  5. Why robocopy only copy directories but not exe files?

    in Windows 10 Network and Sharing
    Why robocopy only copy directories but not exe files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?...
  6. Why robocopy only copy directories but not exe files?

    in Windows 10 Gaming
    Why robocopy only copy directories but not exe files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?...
  7. Why robocopy only copy directories but not exe files?

    in Windows 10 Software and Apps
    Why robocopy only copy directories but not exe files?: I've tried robocopy to directories of programs, However, when I see the consequences, only directories were copied but program files weren't copied. But when I pick exe files to copy, then it is copiedWhy is that, and is there any way to solve this?...
  8. Robocopy automatically taking source directory as the script file directory

    in Windows 10 Network and Sharing
    Robocopy automatically taking source directory as the script file directory: Synopsis:- Script file directory name -> PowerShellScripts in Desktop in local C:\...- Script file name -> Dbackup.ps1- Intended source for mirroring -> D:\ a partition on local hard disk- Intended destination for mirroring -> F:\D_LAPTOP_BACKUP_ ... F: is external SSD...
  9. Robocopy automatically taking source directory as the script file directory

    in Windows 10 Software and Apps
    Robocopy automatically taking source directory as the script file directory: Synopsis:- Script file directory name -> PowerShellScripts in Desktop in local C:\...- Script file name -> Dbackup.ps1- Intended source for mirroring -> D:\ a partition on local hard disk- Intended destination for mirroring -> F:\D_LAPTOP_BACKUP_ ... F: is external SSD...
  10. Robocopy hangs, dependant on working directory

    in Windows 10 Gaming
    Robocopy hangs, dependant on working directory: I'm running robocopy to mirror two folders and have come across a strange situation. I am using the /log switch and when the copy started, no log file was being produced. Further investigation showed that the working directory where the log file was being written didn't have...