Error while moving files :name too long (ENAMETOOLONG)

I am getting name too long (ENAMETOOLONG) when i try to move file from one folder to another.

My code is as given below :yawning_face:

`for i in 1:length(IO)
	mat=match(r".+beta-(\d.\d+)_betaerr(\d.\d+)",IO[i])
	if mat==nothing 
		continue
	end
	ind=tryparse(Float64,mat.captures[1])
	#@show typeof(ind)
	err=tryparse(Float64,mat.captures[2])	
	@show typeof(err)
	print("$err\t")
	if err>ind; continue; end
	if ind<=3.5
	mv("/home/raman/runs_20231114/$IO[i]","/home/raman/GoodPlots/$IO[i]",force=true)
	end
end`

well, your file name is too long:

1 Like

You are using the whole IO (whatever that is, I assume a list of filenames by looking at the error above) in the string interpolation:

mv("/home/raman/runs_20231114/$IO[i]","/home/raman/GoodPlots/$IO[i]",force=true)

since the [i] is not picked up. You can also see it in the syntax colouring, the [i] appears red (in your editor-- in the screenshot above --it’s blue).

This means that the whole IO array is dumped into your mv command, which is obviously too long.

You need to use parentheses to include that in the interpolation:

mv("/home/raman/runs_20231114/$(IO[i])","/home/raman/GoodPlots/$(IO[i])",force=true)

as you can see $(IO[i]) is now “black” that’s what gets replaced by the ith value of IO.

1 Like