0
$\begingroup$

Based on:

CreateDirectory returns the full name of the directory it creates, and $Failed if it cannot create the directory

the following code should return True on each comparison, but it doesn't.

For this reason I wonder if CreateDirectory[], on a succesfull try, gives the same string it got as argument. Please, can you explain ?

By the way, in this site is allowed talking about looking for some sort of employment as Mathematica programmer?

folder = "c:\\something";
If[
  DirectoryQ[folder],
  Quiet[
   DeleteDirectory[folder]
   ], Null, Null
  ];
data = CreateDirectory[folder];
FullForm /@ {folder, data}
folder == data
folder === data
FullForm[folder] == FullForm[data]
FullForm[folder] === FullForm[data]
$\endgroup$
3
  • $\begingroup$ Are you looking for a job? $\endgroup$
    – Jinxed
    Apr 3, 2015 at 22:02
  • $\begingroup$ I'm trying to understand if my skill in Mathematica (and English ...) suffices to decently putting me in for a job and yes, at present I'm looking for a part time job. $\endgroup$ Apr 4, 2015 at 6:11
  • 1
    $\begingroup$ I think you can get what CreateDirectory will return with ExpandFileName without actually creating the directory. For your example I think ExpandFileName[folder]===data should return True when the CreateDirectory was successful... $\endgroup$ Apr 4, 2015 at 10:22

2 Answers 2

1
$\begingroup$

CreateDirectory returns the name of the parent directory as Capital litter

data = CreateDirectory[folder]
(*"C:\\something"*)

When you try to use Equal or similar, it done' know anything about the folder but it compares values in hand.

Defiantly "c:\\something" dose not equal "C:\\something" because the "c" does not equal "C".

To get what you want use :

folder = "C:\\something";

folder == data
folder === data
FullForm[folder] == FullForm[data]
FullForm[folder] === FullForm[data]

(*True*)
(*True*)
(*True*)
(*True*)

For your second question, as far as I know this not a place to post job offers but you can for sure look at the page of the users and if they put their contact you can contact them personally

$\endgroup$
2
  • $\begingroup$ I think this is not completely correct: As I pointed out (and verified) in my answer, CreateDirectory does return not only the parent directory, but the full path. $\endgroup$
    – Jinxed
    Apr 3, 2015 at 22:01
  • $\begingroup$ Capital letters ! I'm ashamed for having asked a such silly question. I should have realized it: I apologise. $\endgroup$ Apr 4, 2015 at 6:04
6
$\begingroup$

CreateDirectory does not return what was input, but the full path to the directory created: Try:

SetDirectory["C:\\Temp"];
CreateDirectory["abcdefg12345"]
(* C:\\Temp\\abcdefg12345 *)

In your case, the difference is between the lowercase "c" and the returned uppercase "C", so the comparison fails for that reason.

$\endgroup$
1
  • 1
    $\begingroup$ there might also other changes be done, see e.g. what CreateDirectory["c:/ttt"] returns on windows, I'd probably formulate that as "does not return what was input, but a normalized full path to the directory created"... $\endgroup$ Apr 4, 2015 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.