Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. batch file and xcopy question

batch file and xcopy question

Scheduled Pinned Locked Moved The Lounge
helpquestion
22 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Dan Neely

    I assume you meant .\ since the other one is used to flag a command. I did try this, it still does the path relative to the location of cmd.exe (C:\windows\), not the folder the batfile I doubleclicked on is located..

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #13

    dan neely wrote:

    I assume you meant .\ since the other one is used to flag a command.

    You are correct. I'm too used to working in Unix for the command line. :laugh:

    dan neely wrote:

    I did try this, it still does the path relative to the location of cmd.exe (C:\windows\), not the folder the batfile I doubleclicked on is located..

    I see what you're saying. Well in that case, as was said already, it uses the CWD. Even running the batch file in the same dir won't work if the CWD isn't set to the dir you need it to be in. What you'll need to do then is pass the directory as a parameter to the batch file so the batch file can resolve the full directory for the xcopy command. Jeremy Falcon

    1 Reply Last reply
    0
    • D Dan Neely

      The level of user I'm dealing with needs open folder X, double click on the icon level instructions. Not goto start-run, etner cmd.exe, type cd type level instructions.

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #14

      If that's the case then the CWD should be set already. Instead of using the command prompt, creat a batch file using the ./ and double it's icon in explorer (the batch file should be in the dir where you want your relative starting point to be). Jeremy Falcon

      1 Reply Last reply
      0
      • S Shog9 0

        %~dp0 That expands to the path where the batch file is located. So, assuming you drop into c:\gimlets a batchfile containing:

        copy "%~dp0MyFile.txt" "%~dp0\backups\"

        ..it'll copy c:\gimlets\MyFile.txt to c:\gimlets\backups\MyFile.txt. :) Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

        ---- Scripts i've known... CPhog 0.9.9 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.1 - printer-friendly forums

        D Offline
        D Offline
        Dan Neely
        wrote on last edited by
        #15

        Shog9 wrote:

        Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

        Cool, that's exactly what I was looking for. Where is the windows helpfile hidden. Having looked at it before I assumed someone as MS decided writing worthless help was one area they could easily surpass *nix and purged where i found it from my memory.

        S N S 3 Replies Last reply
        0
        • D Dan Neely

          Shog9 wrote:

          Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

          Cool, that's exactly what I was looking for. Where is the windows helpfile hidden. Having looked at it before I assumed someone as MS decided writing worthless help was one area they could easily surpass *nix and purged where i found it from my memory.

          S Offline
          S Offline
          Shog9 0
          wrote on last edited by
          #16

          dan neely wrote:

          Where is the windows helpfile hidden.

          On XP, it's called the "Help and Support Center", and initially, there's a link to it from the Start menu. Not sure about previous versions of Windows, i don't really remember ever using it.

          ---- Scripts i've known... CPhog 0.9.9 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.1 - printer-friendly forums

          1 Reply Last reply
          0
          • S Shog9 0

            %~dp0 That expands to the path where the batch file is located. So, assuming you drop into c:\gimlets a batchfile containing:

            copy "%~dp0MyFile.txt" "%~dp0\backups\"

            ..it'll copy c:\gimlets\MyFile.txt to c:\gimlets\backups\MyFile.txt. :) Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

            ---- Scripts i've known... CPhog 0.9.9 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.1 - printer-friendly forums

            S Offline
            S Offline
            Somanova420
            wrote on last edited by
            #17

            Well that's so easy we all should've been born knowing that. %~dp0 <--- Who came up with that

            D S 2 Replies Last reply
            0
            • S Somanova420

              Well that's so easy we all should've been born knowing that. %~dp0 <--- Who came up with that

              D Offline
              D Offline
              Dan Neely
              wrote on last edited by
              #18

              Hey it's something you'll never forget. You can't forget something you never were able to remember in the first place. :-/

              S 1 Reply Last reply
              0
              • D Dan Neely

                Shog9 wrote:

                Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

                Cool, that's exactly what I was looking for. Where is the windows helpfile hidden. Having looked at it before I assumed someone as MS decided writing worthless help was one area they could easily surpass *nix and purged where i found it from my memory.

                N Offline
                N Offline
                Nish Nishant
                wrote on last edited by
                #19

                Yeah, those are pretty handy. BTW just as %~dp0 returns the full path, %~dpnx0 returns the full path with filename. Regards, Nish


                Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                The Ultimate Grid - The #1 MFC grid out there!

                1 Reply Last reply
                0
                • S Somanova420

                  Well that's so easy we all should've been born knowing that. %~dp0 <--- Who came up with that

                  S Offline
                  S Offline
                  Shog9 0
                  wrote on last edited by
                  #20

                  :shrug: If you want intuitive, stay clear of the command line. Cryptic incantations with vast, irreversible results - it's the power we're after here, boy! :)

                  ---- Scripts i've known... CPhog 0.9.9 - make CP better. Forum Bookmark 0.2.5 - bookmark forum posts on Pensieve Print forum 0.1.1 - printer-friendly forums

                  1 Reply Last reply
                  0
                  • D Dan Neely

                    Hey it's something you'll never forget. You can't forget something you never were able to remember in the first place. :-/

                    S Offline
                    S Offline
                    Somanova420
                    wrote on last edited by
                    #21

                    Good point :-O

                    1 Reply Last reply
                    0
                    • D Dan Neely

                      Shog9 wrote:

                      Read up on batchfiles and cmd.exe in the windows help files sometime. It's just about the only useful thing in those helpfiles after all, you might as well get your money's worth...

                      Cool, that's exactly what I was looking for. Where is the windows helpfile hidden. Having looked at it before I assumed someone as MS decided writing worthless help was one area they could easily surpass *nix and purged where i found it from my memory.

                      S Offline
                      S Offline
                      Stuart Dootson
                      wrote on last edited by
                      #22

                      dan neely wrote:

                      Where is the windows helpfile hidden

                      Click on the desktop and press F1 is the way I get at it, then search for 'for' or 'if', to get to the command processor reference.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups