Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how to use use relative path  (Read 3240 times)

0 Members and 1 Guest are viewing this topic.

Blisk

    Topic Starter


    Intermediate

    Thanked: 1
    • Experience: Familiar
    • OS: Windows 7
    how to use use relative path
    « on: May 19, 2017, 05:15:52 AM »
    I try to copy a files from folders to one folder using relative path and doesnt work

    copy all that log files to c:\new

    c:\test\today\first\log\logfile.log
    c:\test\yesterday\first\log\dovecot.log
    c:\test\today\second\log\simple.log
    c:\test\today\third\log\logfile.log
    c:\test\yesteday\fifth\log\mail.log

    I tried this
    copy c:\test\..\..\log\*.log c:\new
    copy "%cd%"log\log\*.log c:\new

    nothing works

    Computer Hope Admin

    • Administrator


    • Prodigy

      Thanked: 248
      • Yes
      • Yes
      • Yes
      • Computer Hope
    • Certifications: List
    • Computer: Specs
    • Experience: Guru
    • OS: Windows 10
    Re: how to use use relative path
    « Reply #1 on: May 19, 2017, 05:26:28 AM »
    The relative path should be relative to what directory you are in when you run the command. So, it all depends on where you are running the copy command from. For example, if you were in the "c:\new>" directory and wanted to copy logs in "c:\test\today\first\log" using a relative path you would type:

    copy ..\test\today\first\log\*.log

    What this command does is first go back one directory since you're in "new" and then from the root goes into test\today\first\log

    Any time you want to move back use ..\ and if there are more than one directories you need to go back you would need to go back multiple times. For example, if you were in c:\test\today\first\log and wanted to copy to the new directory using a relative path you would type:

    copy *.log ..\..\..\..\new

    Of course it would be easier in this example to use a absolute path and type:

    copy *.log c:\new

    Hoep that helps, also you may want to read the below page if you haven't already.

    https://www.computerhope.com/issues/ch001708.htm
    Everybody is a genius. But, if you judge a fish by its ability to climb a tree, it will spend its whole life believing that it is stupid.
    -Albert Einstein

    Blisk

      Topic Starter


      Intermediate

      Thanked: 1
      • Experience: Familiar
      • OS: Windows 7
      Re: how to use use relative path
      « Reply #2 on: May 19, 2017, 12:26:48 PM »
      Thanks
      but how to go in directory forward not backward
      If I have path like this
      c:\test\yesteday\fifth\log\mail.log
      I am in directory test and want to copy files *.log to c:\test1
      than
      copy c:\test\..\..\log\*.log c:\test1
      but that doesn't work