I have a set of files, e.g. file1.dat, file2.dat,... containing data (list of data points to plot, manipulate...) I want to do the following
file1 = Import["file1.dat"];
where variable name
file1 is derived from the imported file name. And then do the same for the chosen filenames in the working directory.
Manual this is done by typing the name of the variable (which is equal to the name of the file), Set, Import the same file:
Making it automatic, I tried in this manner: ToExpression@StringDrop[FileNames[], -4] = Import[FileNames[]]
Where on the left side of Set I try to make a variable name (dropping last four characters of the filename i.e. ".dat") from the first file in the working directory, and import the file with the same name on the right side of Set. But it is not possible to make the variable name on the left side of Set. I get the following response:
Set::write: Tag ToExpression in ToExpression[AlNFeb4data0d30] is Protected. >>
Thank you for the answers, somehow I could not make them work for my case so far.