Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:01 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CHDIR command

Author Message
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 09:37am 26 Jun 2013
Copy link to clipboard 
Print this post

If I have a file structure that is several directories deep.

eg.

B:\DIR1\DIR2\DIR3

and I am currently in DIR3

How do I, in a single command, change back to B:\ ?

I know CHDIR .. takes me back one but CHDIR B:\ doesn't work.

Nick
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 10:38am 26 Jun 2013
Copy link to clipboard 
Print this post

..\..\.. perhaps?
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 10:41am 26 Jun 2013
Copy link to clipboard 
Print this post

wait, chdir never takes a drive anyway. Just chdir \ is supposed to work.

(each drive remembers its path)
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 11:10am 26 Jun 2013
Copy link to clipboard 
Print this post

Probably CHDIR B:\

John
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 11:30am 26 Jun 2013
Copy link to clipboard 
Print this post

  Dylan said   wait, chdir never takes a drive anyway. Just chdir \ is supposed to work.

(each drive remembers its path)

What he said. Follows is a quote from the V4.3a manual.

Change the current working directory on the SD card to ‘dir$’
The special entry “..” represents the parent of the current directory and
“.” represents the current directory.


It looks like you set DIR$ first then issue CHDIR it seems an odd way to do it.
 
shoebuckle
Senior Member

Joined: 21/01/2012
Location: Australia
Posts: 189
Posted: 12:52pm 26 Jun 2013
Copy link to clipboard 
Print this post

  Nick said   If I have a file structure that is several directories deep.

eg.

B:\DIR1\DIR2\DIR3

and I am currently in DIR3

How do I, in a single command, change back to B:\ ?

I know CHDIR .. takes me back one but CHDIR B:\ doesn't work.

Nick


As Dylan says"

CHDIR "..\..\.."

will get you back from DIR3 to B:\

Cheers,
Hugh
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:38pm 26 Jun 2013
Copy link to clipboard 
Print this post

  shoebuckle said   As Dylan says"
CHDIR "..\..\.."
will get you back from DIR3 to B:\
Hugh

Well, there's an answer I should have asked the question to long ago. I've always kept the directory structure just one level deep because of this and it's made my directory lists rather longer than I'd like.

Greg
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 03:51pm 26 Jun 2013
Copy link to clipboard 
Print this post

Yep. Leave out the drive letter.

I don't know which OS I was thinking. :)

Nick
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 10:57pm 26 Jun 2013
Copy link to clipboard 
Print this post

Hello Nick!
if you want to go back to the root, no matter what subdirectory you are, try

Chdir "\"

Juri
 
Dylan
Regular Member

Joined: 17/06/2013
Location: Netherlands
Posts: 81
Posted: 07:41am 27 Jun 2013
Copy link to clipboard 
Print this post

  Juri74 said   Hello Nick!
if you want to go back to the root, no matter what subdirectory you are, try

Chdir "\"

Juri


I must admit, using the quotes is something I fail to do!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024