Copy from CSV and Rename in MS-DOS - copy-paste

I have a .csv file with the following format:
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
<path_including_filename>,<new_filename>
I want to copy what's on column #1 in my CSV from Location A to Location B, then rename the file on Location B with the content of the column #2 in my CSV.
This is what I have done so far, the copying works but the renaming seems doesn't really happen:
For /F "tokens=1* delims=," %%i in (myCSV.csv) do (copy "%%i" "C:/myFolder" && rename "C:/myFolder/%%~nxi" "%%j")
Thanks in advance.

This answer used to contain my wrong suggestion from comments:
When the second column isn't a full pathname, but just a file name, rename "C:/myFolder/%%~nxi" "%%j" takes its destination argument as a path relative to current directory, not to the source directory.
I thought the problem should be solved by providing a full path name in the second argument of rename as well:
rename "C:/myFolder/%%~nxi" "C:/myFolder/%%j"
But no: the full path name is actually invalid in the destination argument for rename. The solution of cding to the target directory first and renaming without folder names in either argument turned out to work. I think that replacing forward slashes with backslashes in the first argument (leaving the second without the folder name) would help too: in my tests on Windows XP, rename failed with "file not found" when a source folder path contained forward slashes, and worked for backslashes.

Related

Erlang : exception error: no match of right hand side value {error,enoent} while reading a text file

I am currenly working on an erlang project and stuck in reading the file. I want to read a text file which is in the /src folder where all the erlang and a text file are in the same structure. Then too, I am not being able to read the file despite of specifying file paths. Any help would be appreciated.
start() ->
{ok,DataList} = file:consult("Calls.txt"),
io:format("** Calls to be made **"),
io:fwrite("~w~n",[DataList]).
The data file stores contents like : {john, [jill,joe,bob]}.
Try add folder name to the path or try set full patch to the file:
1> {ok,DataList} = file:consult("src/Calls.txt").
Notes: the error {error,enoent} mean that the file does not exist or you don't have a rights to read/write current file, for this case need set 777 rights or similar.
If you need to use src/call.txt, then this simply means that your IDE (or you) has created a src folder in which the calls.txt file has been placed. At the same time, the IDE is using a path that only includes the top level folder (i.e., the root folder for the IDE project). So src/call.txt must be used in that case. This isn’t a problem with Erlang, or even the IDE. It’s just the way your project is set up.
You can do either of two things. Move the calls.txt file up one level in the IDE file manager, so that it can be referenced as calls.txt, not src/call.txt. You can also just change the path to “calls.txt” before you run it from the command line.
enoent means "Error: No Entry/Entity". It means the file couldn't be found. When I try your code, it works correctly and outputs
[{john,[jill,joe,bob]}]

Error in Octave while trying to call function: Undefined near line 1 column 1

When I am trying to call a function it gives me an error. However, I checked my destination path which is correct where my ".m" file is save.
Destination path: C:\Users\Soumaditya\Desktop\ML
File name: warmUpExerciseenter image description here
You are probably mistyping something.
At the matlab or octave terminal, from the directory where you expect your .m file to be, type the command what.
This will show you what is actually there which is relevant to matlab / octave.
Another possibility is that you named your function file one thing, but the name of the function inside the file has named it something else (though, in this case, octave at least would probably have thrown a warning...)
Also make sure that your filename doesn't actually have any weird spaces in the name. A file 'myfunction.m ' is not the same as 'myfunction.m' or ' myfunction.m'
You will need to move all the scripts to the default directory for Octave files on your system, move to your home directory on the Ubuntu system.

SP2-0310: unable to open file "dba_files_all.sql"

Please advise. This SQLPlus call:
SQL > #dba_files_all
...is not working.
SP2-0310: unable to open file "dba_files_all.sql"
How can I resolve the error?
You need to provide the path of the file as string.
Put the path in double quotes and it will work.
For example:
#"C:\Users\Arpan Saini\Zions R2\Reports Statements and Notices\Patch\08312017_Patch_16.2.3.17\DB Scripts\snsp.sql";
I encountered this error when attempting to execute a file in the same folder as the calling function. In my example, this process:
Was executed in SQL Developer;
Has been a long-standing part of my system (moving a setup file with some settings and variable names through various folders; those folder names include the feature IDs and a short description);
Has worked fine in the past;
Did not require any pathing in my case because the files were in the same folder;
Failed on the most recent attempt with the error above (SP2-0310).
The issue in my situation was that the folder name in which it failed included a character (#) that was valid for a Windows file name, but confusing to SQL Developer.
1.Use absolute path:
/u01/app/oaracle/test.sql
2.Check the path to see if script exists:
ls -l /u01/app/oaracle/test.sql
Note that
SQL> #some_file.sql
means that sql app you are using will look for that using "absolute path" so if you want to use "relative path" use following format [add ?]
SQL> #?some_file.sql
else, use "full path" with first command.
All the answers so far imply that absolute paths are required. That aren't. Relative paths in sql is pretty universal in sql tools. Sometimes, you have to configure a lost default configuration such as in the case of SQLDeveloper as explained in this answer:
https://stackoverflow.com/a/24003529/442968
I just run into same error when I was trying to unlock oe schema.
While reading the error, I realized that when I run the following line:
>SQL #?/demo/schema/order_entry/oe_main.sql
The error returned a completely different path
SP2-0310: unable to open file "C:/app/USER/product/18.0.0/dbhomeXE/demo/schema/order_entry/oe_main.sql"
Thus I copied my sql file to the path specified by the error and everything worked. I recommend that you do the same. Check the path in the error and adjust accordingly.
Use absolute path or run sqlplus command from a shell/dos that points to the path of the script. Also, to use a masterscript, refer to subscripts with ##.
verify that your file has an extension .sql not .sql.txt

Matlab 'addpath/rmpath' not working in my case

Let me explain my situation with some dummy file names.
I am working in directory 'A' which has a sub directory 'a'. I am running a function 'func1' which is present in both folders. 'func1' needs 'file1' & 'file2' during its execution. 'file1' & 'file2' are present in both folders with some parameters changed inside them. It is not possible for me to change file names at all.
Now, the problem is that when I am running 'func1' in 'A', everything is working fine. But, when I run 'func1' in 'a' using 'addpath/rmpath', rather than using 'file1' & 'file2' from 'a', it is using 'file1' & 'file2' from 'A' which is producing wrong results.
Please tell me how can I change path so that when I run 'func1' in sub directory 'a', it always use 'file1' & 'file2' from 'a' rather than directory 'A'.
I hope I am clear in my explanation :S
If I have understood correctly, you are hoping that if you use addpath to add the subdirectory to the search path, Matlab will give the search path precedence over the current directory. Unfortunately, it is precisely the other way around, as per the Matlab documentation: "Functions in the current folder take precedence over functions with the same file name that reside anywhere on the search path." - and this also applies to the load function when reading data files. (incidentally, I suspect that for this reason you are also not running the version of func1 that you think you are running - try typing which func1 to find out).
Anyway, the solution here is to make sure that Matlab picks the right version of file1 and file2, which you could do in several ways:
Change your working directory to a, since the working directory has precedence: cd a
Put the two versions into separate subfolders, e.g. a and b, and use addpath to add them separatley
Change the different versions of func1 to have explicit references to the files, i.e. load('./a/file1')
With addpath and rmpath you modify the search path in Matlab. Your search path basically is a list of folders where Matlab looks for functions. Not for files you want to open.
If you have your files in folder A and this is your current working directory, Matlab will look for the files in A. If you change to a and change your working directory accordingly, Matlab will open the files in a - this has nothing to do with your search path. If you want to open files from a specific directory, use the entire path in the open command:
fileID = fopen('/path/to/A/file1');
In your case, the case may be that the fopen is applied in the way explained above. If you want Matlab to always open files from the current working directory, change it to:
fileID = fopen('file1');

Name of a path containing the complete file name?

For me, a path was always something that "walks the way to something", but without the "something".
Like a chicken following bread crumbs until it hits the target. But the target is not part of the path. That's what I believe.
So, example: C:/foo/bar = the path. C:/foo/bar/something.html = Path and the "Target".
Can someone tell me what are the correct terms here? How do I call such a path with file?
"Full path"?
"Full qualified path"?
"Path with File Name"? (not precise! "Path with File Name and Extension" ... way too long)
Sure there's a special name for this. Want to know! :)
Nice chicken example... I think you mean absolute path
but, It doesn't matter what the path points to, be it a directory, file, device or otherwise
Wikipedia says:
A path, the general form of a filename or of a directory name, specifies a unique location in a file system.
It doesn't even require an extension, as other mechanisms work out the filetype.
/foo/bar/file.txt = Absolute path
/foo/bar = An absolute path to a directory
../foo = A relative path to a directory, from current directory
./file.txt = A relative path to a file, from current directory (Unix)
file.txt = A relative path too
Also
Systems can use either absolute or relative paths. A full path or absolute path is a path that points to the same location on one file system regardless of the working directory or combined paths. It is usually written in reference to a root directory.
The distinction between files and directories isn't catered for with a path. A path is always a path to something, be it a file or a directory:
/a/b/c is the path to c regardless of what type (file, directory, device) the end point is.
Also checkout basenames
basename is a standard UNIX computer program, when basename is given a pathname, it will delete any prefix up to the last slash ('/') character and return the result. basename is described in the Single UNIX Specification and is primarily used in shell scripts.
From LINFO
A path is the address of an object
(i.e., file, directory or link) on a
filesystem.
So, unfortunately, you are looking for a specificity of terms that isn't part of the accepted usage. You'll have to define your own terms.
I beleive it is called "full name" regardless of the "target" type, just because everything in UNIX is a file, including a directory. So if a foo is the target (as you called it), then foo is the name, while C:\Direcotry\foo or /usr/bin/foo is the foo's full name.
i have been thinking about it too lately, because in Everything, the path do not include the "target" itself. but when i search in Wikipedia, it say that the target is included.
in your example, you have implicitly assume that there is "only one" target at the end of the bread crumbs. and someone tell the chicken to follow the bread crumbs and then it can get to the target.
what if there are 2 objects in the end? if someone did not tell which one is the target, e.g. include the target itself in the path, the chicken will never know its target.
you can also think like this: for a path which include the file, the target is not the file, but its content or some other imformation of the file.
back to the file system, assume there is several file in a folder. if file name is not included in its path, then they all have same path and you can not find a specific file through its path alone.

Resources